我知道它用于使参数成为一个真正的数组,但我不明白使用时会发生什么 Array.prototype.slice.call(arguments)
JavaScript函数可以采用无限制的参数吗?像这样的东西:
testArray(1, 2, 3, 4, 5...);
Run Code Online (Sandbox Code Playgroud)
我在尝试:
var arr = [];
function testArray(A) {
arr.push(A);
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用(输出只是第一个参数).或唯一的方法是:
function testArray(a, b, c, d, e...) {
}
Run Code Online (Sandbox Code Playgroud)
谢谢