Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
arguments is an array-like object accessible inside functions that contains the values of the arguments passed to that function.
Note: In modern code, rest parameters should be preferred.
The arguments object is a local variable available within all non-arrow functions. You can refer to a function's arguments inside that function by using its arguments object. It has entries for each argument the function was called with, with the first entry's index at 0.
For example, if a function is passed 3 arguments, you can access them as follows:
The arguments object is useful for functions called with more arguments than they are formally declared to accept, called variadic functions, such as Math.min(). This example function accepts any number of string arguments and returns the longest one:
You can use arguments.length to count how many arguments the function was called with. If you instead want to count how many parameters a function is declared to accept, inspect that function's length property.
Each argument index can also be set or reassigned:
Non-strict functions that only have simple parameters (that is, no rest, default, or destructured parameters) will sync the new value of parameters with the arguments object, and vice versa:
Non-strict functions that are passed rest, default, or destructured parameters will not sync new values assigned to parameters in the function body with the arguments object. Instead, the arguments object in non-strict functions with complex parameters will always reflect the values passed to the function when the function was called.
This is the same behavior exhibited by all strict-mode functions, regardless of the type of parameters they are passed. That is, assigning new values to parameters in the body of the function never affects the arguments object, nor will assigning new values to the arguments indices affect the value of parameters, even when the function only has simple parameters.
Note: You cannot write a "use strict"; directive in the body of a function definition that accepts rest, default, or destructured parameters. Doing so will throw a syntax error.
arguments is an array-like object, which means that arguments has a length property and properties indexed from zero, but it doesn't have Array's built-in methods like forEach() or map(). However, it can be converted to a real Array, using one of slice(), Array.from(), or spread syntax.
For common use cases, using it as an array-like object is sufficient, since it both is iterable and has length and number indices. For example, Function.prototype.apply() accepts array-like objects.
Reference to the currently executing function that the arguments belong to. Forbidden in strict mode.
arguments.lengthThe number of arguments that were passed to the function.
arguments[Symbol.iterator]()Returns a new array iterator object that contains the values for each index in arguments.
This example defines a function that concatenates several strings. The function's only formal argument is a string containing the characters that separate the items to concatenate.
You can pass as many arguments as you like to this function. It returns a string list using each argument in the list:
This example defines a function that creates a string containing HTML for a list. The only formal argument for the function is a string that is "u" if the list is to be unordered (bulleted), or "o" if the list is to be ordered (numbered). The function is defined as follows:
You can pass any number of arguments to this function, and it adds each argument as a list item to a list of the type indicated. For example:
The typeof operator returns 'object' when used with arguments
The type of individual arguments can be determined by indexing arguments:
| ECMAScript® 2027 Language Specification # sec-arguments-exotic-objects |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.