Home / Advanced JavaScript Tutorial / Creating Robusts Functions |
CodingForums Jump to...
- CSS Drive
- JavaScript Menus - PHP Resources - Hotels & Vacations - Java Online Casinos - Web hosting Search |
With the help of the arguments array, in addition to a minor change when defining a function, we can create a function that accepts any number of parameters. The first order of buisness is to define a robust function. A function as such looks exactly the same as a function with say, two or three parameters, only that the parameters are not explicitly specified. function robust(){ } Now that that's out of the way, the remaining work is to create a mechanism using the arguments array that dynamically retrieves all of the parameters that get passed in, so the remaining portion of the function can do its job with them. A simple for loop will do nicely: function robust(){ -Tutorial introduction |
http://javascriptkit.com |