Answer the question
In order to leave comments, you need to log in
Symbol and for of overload in js?
Hello.
Do I understand correctly that the following code:
let obj = {
to: 10,
[Symbol.iterator]: function () {
let curr = 0;
let stop = this.to;
return {
next() {
if (curr <= stop)
return {
done: false,
value: curr++
}
else
return {
done: true
}
}
}
}
}
for (let num of obj) {
console.log(num);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question