I tried to print an array generated by yield
and somehow if I use for...in statement it creates an array of strings while using regular for loop its working properly.
Why is that happens?
function *hello1(elements) {
for(var el in elements) yield el;
}
function *hello2(elements) {
for(var i=0;i<elements.length;i++) yield elements[i];
}
var elements = [1,2,3];
console.log(elements);
console.log([...hello1(elements)]);
console.log([...hello2(elements)]);