LoginSignup
0
0

More than 3 years have passed since last update.

JavaScript本格入門(ISBN 978-4774184111)で基礎からJavaScriptを勉強するシリーズです。
今回はChapter5からイテレータについてです。

イテレータ

オブジェクトの内容を列挙するための仕組みを備えたオブジェクトのことです。

例えばArrayオブジェクトはイテレータを備えているので、for...ofで呼ぶたびに指しているオブジェクトが変わり、走査することが出来ます。

let team = ['Giorno', 'Bucciarati', 'Mista', 'Fugo', 'Narancia', 'Abbacchio'];

for(let d of team) {
  console.log(d);
}
実行結果
Giorno
Bucciarati
Mista
Fugo
Narancia
Abbacchio

イテレータを備えた組み込みオブジェクトには以下のようなものがあります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0