返回一个数组被截断n个元素后还剩余的元素,从索引0开始截断。
function slasher(arr, howMany) {
// it doesn't always pay to be first
if(howMany<=0)
{
return arr;
}
if(howMany>arr.length)
{
return [];
}
return arr.slice(howMany,arr.length);
}
slasher([1, 2, 3], 2);