★ wanayoo — archive 1999 https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/%40%40iteratorNouvelle recherche | Portail wanayoo

Array.prototype[@@iterator]()

by 1 contributor:

This article is in need of an editorial review.

This translation is incomplete. Please help translate this article from English.

これは Harmony(ECMAScript 6) 提案の一部であり、実験段階の技術です。
この技術の仕様は安定していません。ブラウザ互換性の一覧表を確認してください。またこれらの構文や動作は、仕様変更などにより、新しいバージョンのブラウザでは変更される可能性があるという点に注意してください。

概要

@@iteratorプロパティの初期値はvalues()プロパティの初期値と同じ関数オブジェクトです。

構文

arr[Symbol.iterator]()

例: for...ofループを用いた反復

var arr = ['w', 'y', 'k', 'o', 'p'];
// your browser must support for..of loop
// and let-scoped variables in for loops
for (let letter of arr) {
  console.log(letter);
}

例: 代りの反復

var arr = ['w', 'y', 'k', 'o', 'p'];
var eArr = arr[Symbol.iterator]();
console.log(eArr.next().value); // w
console.log(eArr.next().value); // y
console.log(eArr.next().value); // k
console.log(eArr.next().value); // o
console.log(eArr.next().value); // p

仕様

仕様 状況 コメント
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Array.prototype[@@iterator]()' in that specification.
Standard Initial definition.

ブラウザ実装状況

機能 Chrome Firefox (Gecko) Internet Explorer Opera Safari
基本サポート 38 17 (17) (.iterator)
27 (27) (["@@iterator"])
36 (36) ([Symbol.iterator])
未サポート 25 未サポート
機能 Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
基本サポート 未サポート 未サポート 17.0 (17) (.iterator)
27.0 (27) (["@@iterator"])
36.0 (36) ([Symbol.iterator])
未サポート 25 未サポート

Gecko特有の覚書

  • From Gecko 17 (Firefox 17 / Thunderbird 17 / SeaMonkey 2.14) to Gecko 26 (Firefox 26 / Thunderbird 26 / SeaMonkey 2.23 / Firefox OS 1.2) the iterator property was used (バグ 907077), and from Gecko 27 to Gecko 35 the "@@iterator" placeholder was used instead of the @@iterator symbol (バグ 918828).

関連情報

ドキュメントのタグと貢献者

Contributors to this page: shide55
最終更新者: shide55,
サイドバーを隠す