...

/

Using Custom Iterators

Using Custom Iterators

Learn which data types can be iterated with for loop and which needs symbols to iterate over them.

The built-in collections in JavaScript, like Array, Set, and Map, are all iterable. Using the for loop, we can iterate over them to process the elements. But, what about user-defined classes?

svg viewer

Iterators for user-defined classes

For example, you might create a Car class, and you want the user ...