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:


ECMAScript® 2016 Language Specification#sec-arguments-exotic-objects

Function Topic

  1. JS: Define Function
  2. JS: Functional Programing
  3. JS: Arrow Function
  4. JS: Function Parameters
  5. JS: f Declaration vs Expression
  6. JS: Closure
  7. JS: Function Call, Apply, Bind
  8. JS: Function Argument Default Value
  9. JS: Function Rest Parameters
  10. JS: Function Argument Destructure
  11. JS: Function Object
  12. JS: Function.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

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