arguments function scope variable
  
        JS Home  << 
        JS Reference  << 
        arguments
  
  Array-like object.
Description
The arguments object is a function scope variable that holds a list of the arguments passed to the function.
- The 
argumentsobject is only available within a function and will return an error if used outside the function body. - The 
argumentsobject can be accessed in the same way as an array but noarraylike-methods are available to it exceptlength. - The 
argumentsobject can be be modified using a zero based index. 
Syntax
| Signature | Description | 
|---|---|
arguments[argsInd] | The arguments object is a function scope variable that holds a list of the arguments passed to the function. | 
Parameters
| Parameter | Description | 
|---|---|
argsInd | Optional zero based index for argument retrieval/modification. | 
Examples
The code below gives examples of using the arguments statement.
*/
 / Create a function statement that takes an argument,
 / modifies the argument within the function and 
 / returns the square of the modified argument.
 /*
function squareNumber(a) {
  alert(arguments[0] + ' argument before modification';)
  alert(arguments.length + ' number of arguments';)
  
  arguments[0] *= 2;
  
  alert(arguments[0] + ' argument after modification';)
  
  return a * a;
}
alert(squareNumber(5));
alert(squareNumber(10));
	
	
		Related Tutorials
JavaScript Intermediate Tutorials - Lesson 8 - Functions
