arguments
是一个对应于传递给函数的参数的类数组对象。
function func1(a, b, c) {
console.log(arguments)
// Object { 0: 1, 1: 2, 2: 3 }
console.log(arguments[0]);
// expected output: 1
console.log(arguments[1]);
// expected output: 2
console.log(arguments[2]);
// expected output: 3
}
func1(1, 2, 3);
es6解构赋值有对象和数组
[...aa] = [1, 2, 3];
console.log(aa); //[ 1, 2, 3 ]
函数的解构赋值
function test(...args) {
console.log(args, "数组");
}
test(1, 2, 3);//[ 1, 2, 3 ] 数组
new test(1, 2, 3);//[ 1, 2, 3 ] 数组