The Argument is an array object that have a property of length which enables the programmer to tell how many arguments (or variables) are passed to the function and specify them, without declaring each argument in the function. In the given example, we have passed the arguments in the following way:
days("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
The days.arguments[i] get the specified arguments and displayed on the browser.
Here is the code:
| <html> <head> <h2> Argument Array Example </h2> <script language="JavaScript"> function days() { var items = days.arguments.length for (i = 0;i < items; i++){ document.write("<li>"+days.arguments[i] ); } } days("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); </script> </head> </html> |
Output will be displayed as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: JavaScript Array Arguments
Post your Comment