O'Reilly logo

Understanding ECMAScript 6 by Nicholas C. Zakas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8ITERATORS AND GENERATORS

image

Many programming languages have shifted from iterating over data with for loops, which requires initializing variables to track position in a collection, to using iterator objects that programmatically return the next item in a collection. Iterators make working with collections of data easier, and ECMAScript 6 adds iterators to JavaScript. When coupled with new array methods and new types of collections (such as sets and maps), iterators are essential for efficient data processing and you’ll find them in many parts of the language. The new for-of loop works with iterators; the spread operator (...) uses iterators; and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required