A 12 year old Nirof along with some of her friends is playing the blind man's buff in the community park. Nirof is blindfolded so she'd just run into anyone (friends and strangers). Since she can not free her eyes, there is simply no way she can tell who she catches hold of. Her friends while trying to save themselves would also run into people, they could however identify the people they do not know. What am I even saying? I will finish the story (not really a story) towards the end of the post. Before we delve into the real deal, let us try to understand something much important and way much easier to grasp. Let us talk about Enumerables and Iterables.
Blind Man's Buff.
Enumerables VS Iterables
For simplicity just remember the following two points before I elaborate on them:
This will get clearer with an example. Array, String, Map etc. have internally implemented the '@@iterator' function all in their own way. A "for...of" loop on an Array object returns elements of the array one by one because the '@@iterator' function it implements is designed to do so. For no other reason, a "for...of" loop on a String object, gives the characters that make up the string.
Iteration Example. Try on codepen.
Enumeration Example. Try on codepen.
3 - Simple Objects - Non-iterable & Support Enumeration
4 - Arrays, Strings etc.. - Iterable & Support Enumeration