This question already has answers here:
In JavaScript ES6, what is the difference between an iterable and iterator?
(2 answers)
Closed 4 years ago.
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).