Javascript 如何删除arguments对象中的第一个参数?
我需要删除Javascript 如何删除arguments对象中的第一个参数?,javascript,object,arguments,Javascript,Object,Arguments,我需要删除arguments对象中的第一项,以便我的let args变量等于以下所有参数。 我怎么做 function destroyer(arr) { let myArr = arguments[0]; let args = arguments; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); 使用slice检索超过第一个参数的参数,并在函数参数中使用rest参数而不是单个arr,如果可以的话-许多林特建议不要使用参数,此处不必使用该关键字: 函数销
arguments
对象中的第一项,以便我的let args
变量等于以下所有参数。
我怎么做
function destroyer(arr) {
let myArr = arguments[0];
let args = arguments;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
使用
slice
检索超过第一个参数的参数,并在函数参数中使用rest参数而不是单个arr
,如果可以的话-许多林特建议不要使用参数
,此处不必使用该关键字:
函数销毁程序(…args){
const otherArgs=args.slice(1);
log('length:'+otherArgs.length,'items:'+otherArgs);
}
驱逐舰([1,2,3,1,2,3],2,3)
使用slice
检索超过第一个参数的参数,并在函数参数中使用rest参数而不是单个arr
,如果可以的话-许多林特建议不要使用参数
,此处不需要使用该关键字:
函数销毁程序(…args){
const otherArgs=args.slice(1);
log('length:'+otherArgs.length,'items:'+otherArgs);
}
驱逐舰([1,2,3,1,2,3],2,3)代码>最简单的方法:
function destroyer(...arr) {
arr.shift();
console.log( arr ); // 2,3
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
最简单的方法:
function destroyer(...arr) {
arr.shift();
console.log( arr ); // 2,3
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
不太清楚您在这里需要什么。arguments=arguments。splice(0,1)
是您在destroyer()
函数中需要的东西。不太清楚您在这里需要什么。arguments=arguments。splice(0,1)
是您在destroyer()
函数中需要的东西。