Wrapping Up
The newly introduced Symbol primitive type is useful to define properties and methods with unique names, like [Symbol.iterator], for example. The enhanced for loop provides an elegant, less noisy syntax, to iterate over collections of objects. To facilitate iteration over user-defined classes, JavaScript supports custom iterators and generators. The generators are lazy evaluators and may be used to create infinite streams of data.
So far we have used regular functions. In the next chapter you’ll learn about the pros and cons of arrow functions.
Exercises
You learned about Symbols, iterators, and generators, and these are some of the most important and highly used features of JavaScript. These practice exercises will help you to review ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access