arguments 属性(函数)(JavaScript)

转载:http://msdn.microsoft.com/zh-cn/library/he95z461(v=vs.94).aspx

获取当前正在执行的 Function 对象的参数。

function.arguments

 

备注

function 参数是当前正在执行的函数的名称,且可以省略。

此属性使函数可以处理可变数量的参数。 arguments 对象的 length 属性包含了传递给函数的参数数目。 arguments 对象中包含的各个参数的访问方式与数组元素的访问方式相同。

 

示例

下面的示例阐释了 arguments 属性的用法:

 1 function ArgTest(arg1, arg2){
 2    var s = "";
 3    s += "The individual arguments are: "
 4    for (n = 0; n < arguments.length; n++){
 5       s += ArgTest.arguments[n];
 6       s += " ";
 7    }
 8    return(s);
 9 }
10 console.log(ArgTest(1, 2, "hello"));
11 // The individual arguments are: 1 2 hello

 

要求

在以下文档模式中受支持:Quirks、Internet Explorer 6 标准模式、Internet Explorer 7 标准模式、Internet Explorer 8 标准模式、Internet Explorer 9 标准模式、Internet Explorer 10 标准模式和 Internet Explorer 11 标准模式。此外,也在应用商店应用(Windows 8 和 Windows Phone 8.1)中受支持。

 

posted @ 2014-08-26 16:09  johnnylion  阅读(163)  评论(0编辑  收藏  举报