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:

No comments: