JS: Function's “arguments” Object

By Xah Lee. Date: . Last updated: .

There's a predefined variable named arguments inside the function body. It is a array-like object. Each slot is the value of argument.

Note, Arrow Function does not have the arguments object.

[see JS: Arrow Function]

function ff() {
    return arguments; // return the arguments object

// { '0': 3, '1': 4, '2': 5 }

When you define a function (except arrow function), you do not necessarily need to declare any parameters. The arguments can always be accessed via the object arguments in the function body.

「arguments」 is Array-Like Object

// “arguments” is a array-like object

function ff() {
    return Array.isArray(arguments);

console.log ( ff() ); // false

[see JS: Array-Like Object]

ES2015 Features Obsolete Arguments Object

Tip: you should avoid using the arguments object as much as possible. It makes code hard to understand, and has optimization problems.

ES2015 has features that obsolete the need for the argument object. See:

JS Function

  1. Define Function
  2. Arrow Function ⭐
  3. Function Params
  4. “arguments” Object
  5. Rest Params ⭐
  6. Arg Default Value ⭐
  7. Arg Destructure ⭐
  8. f Declaration vs Expression
  9. Closure
  10. f call apply bind
  11. Functional Programing

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials