标签:nta 修改 写入 def 参数 cti 保存 参与 fine
arguments是用来保存函数实参的对象,它在函数创建时会自动创建,在函数调用时会初始化。它保存有实参的值,callee属性(函数的指针),length属性(传入实参的数量)
function a(val) {
console.log(val); //3
console.log(arguments[0]); //3
arguments[0] = 7;
console.log(val); //7
val = 10;
console.log(arguments[0]);//10
}
a(3);
function a(val) {
console.log(val); //undefined
console.log(arguments.length); //0
arguments[0] = 7;
console.log(val); //undefined
console.log(arguments.length); //0
val = 10;
console.log(arguments[0]); //7
}
a();
function a(val1, val2) {
console.log(val1, val2); //3,undefined
console.log(arguments[0], arguments[1], arguments.length); //3,undefined,1
val1 = 10;
val2 = 20;
console.log(val1, val2); //10,20
console.log(arguments[0], arguments[1], arguments.length); //10,undefined,1
arguments[1] = 30;
console.log(val2);//20
}
a(3);
function a(val1, val2 = 5) {
console.log(val1, val2); //7,5
console.log(arguments[0], arguments[1], arguments.length); //7,undefined,1
val1 = 10;
val2 = 20;
console.log(val1, val2); //10,20
console.log(arguments[0], arguments[1], arguments.length); //7,undefined,1
}
a(7);
标签:nta 修改 写入 def 参数 cti 保存 参与 fine
原文地址:https://www.cnblogs.com/Syinho/p/13231577.html