Thursday, November 3, 2011

Java Script Variable Number of arguments


Hi Guys,
As we know we can have the advantage of the  var args(variable number of arguments or variable length arguments ) in Java. Same as in java we have the advantages of var args in java script also.To achieve the variable number of arguments we have a key word called arguments which works only inside of the java script functions.

A pseudo code for that is as follows
----------------------------------------------- 

function test() {
alert(arguments.length);
for(var i=0;i< arguments.length; i++){
alert(arguments[i]);
}
}

and the method call would be

test('13',15,'15');
test('13',15);
test('13');



Please follow the link....

http://www.jtricks.com/javascript_tutorials/varargs.html

No comments:

Post a Comment