From the output of following snippets, I can conclude the following. But not sure if they are correct or not.
i) for...of
can be used both for iterable
and iterator
ii)for...in
can only used for iterable
and not for iterator
var array1 = ['a', 'b', 'c'];
var iterator = array1.keys();
for (let key of iterator) {
console.log(key); // 0 1 2
}
for (let value of array1) {
console.log(value); // 'a' 'b' 'c'
}
for (var index in array1) {
console.log(array1[index]); // 'a' 'b' 'c'
}
for (var key in iterator) {
console.log(key); // `Not executed`
}