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. ...

Get Eloquent JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.