arguments[Symbol.iterator]()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2016.
- spread syntax and array iterator object that yields the value of each index in the
arguments
object.The initial value of this property is the same function object as the initial value of the
Array.prototype[Symbol.iterator]()
).
Syntax
js
arguments[Symbol.iterator]()
Parameters
None.
Return value
The same return value as iterable, and iterating syntaxes like the for...of
loop automatically call this method to obtain the iterator to loop over.
js
function f() {
for (const letter of arguments) {
console.log(letter);
}
}
f("w", "y", "k", "o", "p");
Manually hand-rolling the iterator
You may still manually call the next()
method of the returned iterator object to achieve maximum control over the iteration process.
js
function f() {
const argsIter = arguments[Symbol.iterator]();
console.log(argsIter.next().value); / w
console.log(argsIter.next().value); / y
console.log(argsIter.next().value); / k
console.log(argsIter.next().value); / o
console.log(argsIter.next().value); / p
}
f("w", "y", "k", "o", "p");
Specifications
Specification |
---|
ECMAScript® 2026 Language Specification # sec-createmappedargumentsobject |