[functionObject.]arguments
arguments
属性是正在执行的函数的内置属性,返回该函数的arguments
对象。arguments
对象包含了调用该函数时所传入的实际参数信息(参数个数、参数值等)。javascript
该属性属于Function
对象,全部主流浏览器均支持该属性。java
arguments
属性的值为Object类型,返回正在执行的当前函数的arguments
对象。数组
arguments
对象包含调用该函数时所传入的实际参数信息,例如:参数的个数和参数的值。咱们能够经过arguments
属性让函数处理可变数量的参数。浏览器
arguments
对象有如下三个属性:函数
arguments[0]
能够访问传入的第1个参数,arguments[1]
能够访问传入的第2个参数。
arguments
对象具备length
属性和0...n
属性,看起来与数组的访问方式相同,但arguments
并非数组,它没有数组对象所具有的其余成员属性和方法。spa
function test(){ console.log(arguments.length); // 实际传入的参数个数:3 /* "test."能够省略 */ for(var i = 0; i < test.arguments.length; i++){ console.log("传入的第" + (i + 1) +"个参数:" + arguments[i]); } // 传入的第1个参数:1 传入的第2个参数:张三 传入的第3个参数:true // callee属性返回的就是当前函数 console.log( arguments.callee === test ); // true }; test(1, "张三", true);