What is the difference between Iterator and Iterable? Is one sub-type of the other or not? What are the actual differences in some real applications?
I am trying to read some tutorials and specifications, but they are all very complicated.
(I am using ES6 and Babel, if that helps.)
From Exploring ES6 by Dr. Axel Rauschmayer:
An iterable is a data structure that wants to make its elements accessible to the public. It does so by implementing a method whose key is Symbol.iterator. That method is a factory for iterators.
An iterator is a pointer for traversing the elements of a data structure (think cursors in databases).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With