You are previewing Eloquent JavaScript.

Eloquent JavaScript

Cover of Eloquent JavaScript by Marijn Haverbeke Published by No Starch Press
O'Reilly logo

Some More Theory

Now that you are aware of the existence of arrays and objects, I can clarify a few issues that were glossed over before.

The arguments Object

Whenever a function is called, a special “magic” variable named arguments is added to the environment in which the function body runs. This variable refers to an object that resembles an array. It has a property 0 for the first argument, 1 for the second, and so on, for every argument the function was given. It also has a length property.

However, the arguments object is not a real array—it does not have methods like push, and it does not automatically update its length property when you add something to it. This is an unfortunate heritage of the haphazard way in which the language has grown. ...

The best content for your career. Discover unlimited learning on demand for around $1/day.