返回一個數組被截斷n個元素後還剩餘的元素,從索引0開始截斷。html
function slasher(arr, howMany) { // it doesn't always pay to be first var arrLength = arr.length; var spliceLength = arrLength - howMany; var spliceArr; spliceArr = arr.splice(howMany, spliceLength); return spliceArr; } slasher([1, 2, 3], 2);