jskatas.org Continuously Learn JavaScript. Your Way.

function API: function.arguments (as introduced in ES1)

The arguments property of a function is an object that contains all the arguments passed to the function.

The arguments prop - discouraged since 1997 (and might not work)

WHEN reading arguments in the function body THEN it is an array-like object containing all parameters the function was called with
let args; const fn = function() { args = arguments; } fn(1, 'abc', {x: 'y'}); assert.deepStrictEqual(Array.from(args), [1, 'abc', {x: 'y'}]);
WHEN arguments is defined inside a function THEN this is NOT overridden
//: {"jskatas": {"runnerOptions": {"strictMode": false}}} const fn = function() { const arguments = 'arg'; return arguments; } assert.equal(fn('the argument'), 'arg');

Links

The very first version of the spec defines this property already, the ES1 spec, see section 15.3.5.3 (PDF 732kB).

Related Katas

function API

Arrow functions

Async Function

Difficulty Level

BEGINNER

Stats

2 tests to solve