DEV Community

Discussion on: 💡🎁 JavaScript Visualized: Generators and Iterators

Collapse
 
oosharma profile image
Abhishek Sharma • Edited

I think there's maybe a minor correction, where you state that a Generator's return value is an iterator object since it follows the iterator protocol as they implement the @@iterator method stored in their key [Symbol.iterator] ... so, technically, an object follows the iterator protocol when they implement the next() method, and it follows the iterable protocol when it implements the @@iterator method.

By the way, I couldn't figure out when exactly can we call an object and iterator. What if an object implements just the next() method, or just the @@iterator method, will it be an iterator? Also, would it make sense to have just one of those methods ... I guess I'll keep reading more on it.

Anyways, thanks so much for posting such timeless, incredibly valuable, and easier to digest study materials :)