`@@iterator` 属性的初始值与 `entries` 属性的初始值是同一个函数对象。

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

## 语法

    myMap[Symbol.iterator]

### 返回值

map 的 iterator 函数默认就是 `entries()` 函数。

## 示例

### 使用 `[@@iterator]()`

    var myMap = new Map();
    myMap.set('0', 'foo');
    myMap.set(1, 'bar');
    myMap.set({}, 'baz');

    var mapIter = myMap[Symbol.iterator]();
    //返回的其实是个generator
    console.log(mapIter.next().value); // ["0", "foo"]
    console.log(mapIter.next().value); // [1, "bar"]
    console.log(mapIter.next().value); // [Object, "baz"]

### 在`for..of中`使用`[@@iterator]()`

    var myMap = new Map();
    myMap.set('0', 'foo');
    myMap.set(1, 'bar');
    myMap.set({}, 'baz');

    for (const entry of myMap) {
      console.log(entry);
    }
    // ["0", "foo"]
    // [1, "bar"]
    // [{}, "baz"]

    for (var v of myMap) {
      console.log(v);
    }

    // 0: foo
    // 1: bar
    // [Object]: baz

## 规范

Specification | Status | Comment
--- | --- | ---
ECMAScript 2015 (6th Edition, ECMA-262) Map.prototype[@@iterator]() | Standard | Initial definition.
ECMAScript Latest Draft (ECMA-262) Map.prototype[@@iterator]() | Draft |

## 浏览器兼容

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

Update compatibility data on GitHub

| Desktop | Mobile | Server
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet | Node.js
`@@iterator` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 36 Full support 36 No support 27 — 36 Notes Alternate Name Notes A placeholder property named `@@iterator` is used. Alternate Name Uses the non-standard name: `@@iterator` No support 17 — 27 Notes Alternate Name Notes A placeholder property named `iterator` is used. Alternate Name Uses the non-standard name: `iterator` | IE No support No | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 36 Full support 36 No support 27 — 36 Notes Alternate Name Notes A placeholder property named `@@iterator` is used. Alternate Name Uses the non-standard name: `@@iterator` No support 17 — 27 Notes Alternate Name Notes A placeholder property named `iterator` is used. Alternate Name Uses the non-standard name: `iterator` | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support 0.12

### Legend

Full support
  Full support
No support
  No support
See implementation notes.
  See implementation notes.
Uses a non-standard name.
  Uses a non-standard name.

## 另见

- `Map.prototype.entries()`
- `Map.prototype.keys()`
- `Map.prototype.values()`