Skip to the workspace
Pebellslearn by building
Functions  ›  Lesson

The arguments Object

arguments object 12 min

javascript / The arguments Object

Explore each scene at your own pace.

01 · The arguments Object

The arguments Object

The arguments Object

arguments is an array-like object available inside ordinary functions. It contains the arguments supplied to that invocation; arrows use a surrounding arguments binding instead of creating one.

Named parameters and supplied arguments are related, but a function can inspect extra arguments too.

See the mechanism

Walk through the modelThe arguments ObjectAuthored snapshots of the example; use Run below to test the code.
named parameters1
The declaration names a.
1 of 3

Follow one example

javascript

Only a is named, but the call supplies two arguments. arguments.length is 2 and arguments[1] is "B". It is not an Array, so array methods are not directly supplied by that object. Prefer rest parameters in new code when you want a real array. An arrow does not create its own arguments object.

Predict, change and check

Predict: If supplied is called with no arguments, will arguments.length count the declared parameter a?

Test your explanation: Compare supplied(), supplied("A") and supplied("A", "B"). Count actual supplied values, not parameter names.

The tasks below ask you to explain that result and apply the idea to different inputs.

Apply and distinguish

Array-like is an API distinction

arguments reflects the actual supplied arguments to an ordinary function call, not the number of named parameters in its declaration. It has length and indexed access but is not an Array. Rest parameters produce an actual array and often express a new function's contract more clearly.

Non-strict functions with simple parameters can have special linkage between arguments entries and named parameters; strict mode and non-simple parameter lists change that behavior. Do not rely on that historical aliasing for a new API. An arrow captures an outer arguments binding rather than introducing its own.

Check your understanding: State the input contract, identify the operation that changes the result, and give one boundary input that would distinguish the correct rule from the mistake described above.

Scene 1 of 2
Project context and further resources
Additional resources
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.