Tuesday, November 8, 2011

arguments property of Javascript function

Javascript arguments property inside any function is array of function parameters passed. An arguments property is available only inside the function. Any function parameter can be accessed from the arguments property as usual array indexed by number starting from 0. Lets take an example.

argumentExample=function()
alert(arguments.length);
for loop counter between 0 and arguments.length
alert(arguments[counter]);

argumentExample("firstItem","secondItem",232,"fourthItem");

No comments: