JavaScript: Function's “arguments” Object

By Xah Lee. Date: . Last updated: .

There's a predefined variable named arguments in function defined using keyword function. The arguments object is a Array-Like Object. Each slot is the value of argument.

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

console.log(
 ff(3,4,5)
);
// { '0': 3, '1': 4, '2': 5 }

When you define a function using the keyword 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

JS2015 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.

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

JavaScript Function

JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS in Depth

Basic Syntax

Value Types

Variable

String

Function

Property

Object and Inheritance

Array

Constructor/Class

Iterable 🌟

Misc