The Arguments object has one very unusual feature. When a function has named arguments, the array
elements of the Arguments object are synonyms for the local variables that hold the function arguments.
The arguments[] array and the named arguments are two different ways of referring to the same variable.
Changing the value of an argument with an argument name changes the value that is retrieved through
the arguments[] array. Conversely, changing the value of an argument through the arguments[] array
changes the value that is retrieved by the argument name.
Finally, bear in mind that arguments is just an ordinary JavaScript identifier, not a reserved word. If a
function has an argument or local variable with that name, it hides the reference to the Arguments object.
For this reason, it is a good idea to treat arguments as a reserved word and avoid using it as a variable
name.
本文详细介绍了JavaScript中Arguments对象的独特之处:当函数拥有命名参数时,Arguments对象的数组元素会成为持有函数参数的局部变量的同义词。通过命名参数改变参数值会影响到Arguments[]数组获取的值,反之亦然。此外,文章还提醒开发者避免将arguments用作变量名。

1347

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



