Generators require a mind switch to be used regularly. And the browser is not the place where the most obvious use cases are, so it's harder to make your first steps here.
The easiest things to start using generators is to write sysadmin scripts that parse big files. Once you've done that, you get the memory benefit. Then the more you use it, the more you get the lazy evaluation benefit and you start using it elsewhere.
It's clearer in Python because:
- generators have there for ever
- we have unified way of iterating on things, and generators just work transparently
- you can start learning generators by just changing [] to () in your comprehension lists
The easiest things to start using generators is to write sysadmin scripts that parse big files. Once you've done that, you get the memory benefit. Then the more you use it, the more you get the lazy evaluation benefit and you start using it elsewhere.
It's clearer in Python because:
- generators have there for ever
- we have unified way of iterating on things, and generators just work transparently
- you can start learning generators by just changing [] to () in your comprehension lists
So in JS it's much less obvious.