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
1Follow one example
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.