this code
let func = function *(){
for (let i = 1; i < 5; i++) {
yield i;
}
}
let s = func().next();
console.log(s);
let s2 = func().next();
console.log(s2);
returns
Object {value: 1, done: false}
Object {value: 1, done: false}
so basically func yields first value all the time.
But when I change to
let f = func();
let s = f.next();
console.log(s);
let s2 = f.next();
console.log(s2);
it works as expected. Why assigning func to variable makes such a difference?
func() !== func()?