标签:value under which com define nes hat pre ext
Iterators are the foundation of generators. Much of the misunderstanding around generators comes from the lack of understanding iterators. An iterator has a Symbol.iterator
property with an object that contains a next
method which defines what is output each iteration.
let i = 0 const next = () => ({ value: i++, done: i > 10 }) const iterator = { [Symbol.iterator]() { return { next } } } for (let value of iterator) { console.log(value) }
[Javascript] Create Your First Iterator in JavaScript
标签:value under which com define nes hat pre ext
原文地址:https://www.cnblogs.com/Answer1215/p/12111166.html