Lesson 23. Iterables

After reading lesson 23, you will

  • Know what an iterable is and how to use it
  • Know how to use the spread operator on iterables to ungroup an object’s items
  • Know how to use iterables in a for..in statement to loop over an object’s values
  • Know how to create your own iterables
  • Know how to customize the behavior of built-in iterables

JavaScript in ES2015 has introduced a couple of new protocols: the iterable protocol and the iterator protocol. Together these protocols describe the behavior and mechanics of objects that can be iterated—that is to say, objects that produce a series of values and can have their values looped over. When you think of objects that can be iterated, Array probably springs to mind, but you can also ...

Get Get Programming with JavaScript Next now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.