Iterator 是 ES6 引入的一种新的遍历机制,迭代器有两个核心概念:
const items = ["zero", "one", "two"]; const it = items[Symbol.iterator](); it.next(); >{value: "zero", done: false} it.next(); >{value: "one", done: false} it.next(); >{value: "two", done: false} it.next(); >{value: undefined, done: true}