Home > Blockchain >  How are custom Iterables useful in JS? What are some common usecases of thing that can't be don
How are custom Iterables useful in JS? What are some common usecases of thing that can't be don

Time:10-27

I'm taking about making you own iterable using [Symbol.iterator] - I know how it technically works, but I cannot think of a genuine usecase. What can you do with this?

CodePudding user response:

The most common use case is to create a custom iterator for a custom data structure. For example, if you have a tree data structure, you can create an iterator that traverses the tree in a specific order (e.g. depth-first).

  • Related