javascript-arguments Posted on 2024-12-13 Edited on 2025-04-07 In javascript Symbols count in article: 141 Reading time ≈ 1 mins. Introductionarguments是一个类数组对象,包含了函数调用时传入的所有参数。arguments对象只有在函数内部才可以使用。 访问arguments对象123456function add(a, b) { console.log(arguments[0], arguments[1]); return a + b;}add(1, 2); // output: 1 2 通过arguments对象可以改变函数参数的值 改变arguments时,函数参数的值也会改变。 123456function add(a, b) { arguments[0] = 10; console.log(a);}add(1, 2); // output: 10 改变函数参数时,arguments对象的值也会改变。 123456function add(a, b) { a = 10; console.log(arguments[0]);}add(1, 2); // output: 10