问题:
返回一个数组被截断 n 个元素后还剩余的元素,从索引 0 开始截断。
解答:
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);
链接:
https://www.w3cschool.cn/code…