[1,2,3].slice(1)//[2, 3]
function t(){
//arguments.slice(1);//won't work. Can not directly slice the arguments. You can think it is not an array
var b=[].slice.call(arguments,1);
console.log(b);
}
t(1,2,3);
slice a javascript funtion arguments
最新推荐文章于 2026-01-07 00:05:42 发布
本文介绍了一种在JavaScript中处理非数组对象arguments的方法,通过将arguments转换为真正的数组来实现对其元素的操作,如切片(slice)等。这种方式在编写需要处理多个参数的函数时非常有用。
347

被折叠的 条评论
为什么被折叠?



