Pages

Thursday, November 10, 2011

Arguments to functions in JavaScript

Watching Douglas Crockford's talk about functions in JavaScript, there were a few interesting moments where I learned some new things. One notable detail worth writing down is that every function in JavaScript always receives two arguments: this and arguments.

arguments is array-like but is not an array and contains all the arguments passed to the function.

this contains a reference to an object that contains the function.

Some references:

http://www.devguru.com/technologies/ecmascript/quickref/arguments.html

https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope

http://javascript.crockford.com/

No comments: