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
I agree it doesn't seem super useful, but it can be used to pull some semantic tricks. I used it in [Rebridge](https://github.com/CapacitorSet/rebridge/) to implement syntactic sugar for database access, so that accessing a property on an object translates transparently to a query, and I've seen it used to [allow for typos in property names](https://github.com/mathiasbynens/tpyo).
I especially liked the "construct" part as we can use it to take input from the users in frontend as a numbered value and then store it in the database with the currency format which can be later used to make the value visible with the currency in the frontend.
It's such a niche feature. And only useful if you use mutative OO style.
Also it gets a bit too much into the magic territory for me, this is hard to debug and reason about, even harder than getter/setters.
It's a feature you'll probably end up using all the time without even noticing it.
I just wrote a class to keep track of changes to an object using proxies yesterday. That way you can pass an object to a form, modify it in place and then roll back if needed. Also makes it easy to get deltas and only post the updates to the backend.
Proxies are a basic feature that should be a part of any OO language. Their usefulness ranges from "save yourself a lot of repetitive work" to "impossible to implement without".
Very simple real-life use case: factor out logging and move it outside of normal logic of the object.