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);
}