Js Arguments

The arguments object is a local variable available within all functions; arguments as a property of Function can no longer be used.

You can refer to a function’s arguments within the function by using the arguments object. This object contains an entry for each argument passed to the function, the first entry’s index starting at 0. For example, if a function is passed three arguments, you can refer to the argument as follows:

arguments[0]
arguments[1]
arguments[2]

The arguments object is not an array. It is similar to an array, but does not have any array properties except length. For example, it does not have the pop method. However it can be converted to a real array:

var args = Array.prototype.slice.call(arguments);

The arguments object is available only within a function body. Attempting to access the arguments object outside a function declaration results in an error.

You will get more details about this topics here:
https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments
**Another well explanation will found here:
http://blog.sebarmeli.com/2010/11/12/understanding-array-prototype-slice-applyarguments/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s