JS: Function's “arguments” Object

By Xah Lee. Date: . Last updated: .

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

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

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

Note, Arrow Function does not have the arguments object.

[see JS: Arrow Function]

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: Arrow Function
  3. JS: Function Parameters
  4. JS: var/function Declaration Order
  5. JS: var Name Scope
  6. JS: Function Declaration vs Function Expression
  7. JS: Closure
  8. JS: Functional Programing
  9. JS: Function Call, Apply, Bind
  10. JS: Function Argument Default Value
  11. JS: Function Rest Parameters
  12. JS: Function Argument Destructure

  1. JS: Function Object
  2. JS: Function.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon