The number of arguments passed to a function when it is called.
The length property of the Arguments object can be inspected or used in an enumeration loop to access each argument in turn.
Even if no placeholder arguments are specified, you can still call a function and pass as many arguments to it as you like. They will be assembled into an array that you can manipulate in the way you would normally operate on any other array. You can build enumerators to process all the elements and do something with them.
You can compare this value with the arity property of the owner function object. This will allow you to determine whether the correct number of arguments was passed.
<SCRIPT>// Declare a function that processes a variable number of arguments function summate() { var total = 0; for(var ii=0; ii<arguments.length; ii++) { total += arguments[ii]; } return total; } // Call the function sum = summate(1, 2, 3, 4, 5); document.write(sum); </SCRIPT>
Prev | Home | Next |
Arguments.caller | Up | arguments[] |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |