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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.