Implicit Javascript Variables

December 5, 2007 § Leave a comment

These are javascript variables that I often forget existed because they are implicit but nonetheless very useful.

I’m putting them here just so that I won’t forget anymore. Hope readers found them useful as well.

Arguments, it is a local variable exists in all functions. Based on MozDev documentation, 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 array object via:

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

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

Function Names, when creating a function using “function declaration”, for example:

function iamawesome() { return 5; }

a variable called iamawesome is created implicitly. Thus, you can pass around function as a variable (callback to be exact).


References:

MozDev Functions:Arguments

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

What’s this?

You are currently reading Implicit Javascript Variables at RAPD.

meta

%d bloggers like this: