JavaScript Array Arguments

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.


 
Ads

JavaScript Array Arguments

     

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:

Download Source Code

Advertisements

Ads
Share on Google+Share on Google+

JavaScript Array Arguments

Posted on: November 11, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: JavaScript Array Arguments  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads