javascript:iterator
差分
このページの2つのバージョン間の差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
| javascript:iterator [2014/01/08 02:01] – 作成 nullpon | javascript:iterator [2015/10/24 04:28] (現在) – 削除 nullpon | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | ====== Iterator ====== | ||
| - | Iterator(イテレータ)は[[javascript: | ||
| - | |||
| - | ===== Iterableオブジェクト ===== | ||
| - | Array、NodeList、Arguments、Set、Map等はIterableである。Iterableなオブジェクトはfor-of文で反復処理を行う事が出来る。 | ||
| - | |||
| - | <code javascript> | ||
| - | for (let i of [" | ||
| - | console.log(i); | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | iteratorメソッドを実装しているオブジェクトがiterableとなる。iteratorメソッドはiteratorオブジェクトを返す。 | ||
| - | |||
| - | <code javascript> | ||
| - | console.log([1, | ||
| - | </ | ||
| - | |||
| - | iteratorオブジェクトはnextメソッドを実装していなくてはならない。nextメソッドはiterableの要素を1つずつ取り出すメソッドである。 | ||
| - | |||
| - | <code javascript> | ||
| - | console.log([1, | ||
| - | </ | ||
| - | |||
javascript/iterator.1389146498.txt.gz · 最終更新: by nullpon