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 ...

Get Understanding ECMAScript 6 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.