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

arguments 对象的 [Symbol.iterator]() 方法实现了可迭代协议并允许 arguments 对象被大多数期望可迭代对象的语法消费,例如展开语法for...of 循环。它返回一个数组迭代器对象,该对象会产生 arguments 对象中每个索引的值。

语法

js
arguments[Symbol.iterator]()

示例

使用 for...of 循环的迭代

js
function f() {
  // 你的浏览器必须支持 for..of 循环
  // 以及 for 循环中的 let 区域变量
  for (let letter of arguments) {
    console.log(letter);
  }
}
f("w", "y", "k", "o", "p");

规范

Specification
ECMAScript® 2025 Language Specification
# sec-createunmappedargumentsobject
ECMAScript® 2025 Language Specification
# sec-createmappedargumentsobject

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
[Symbol.iterator]

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见