Skip to content

Instantly share code, notes, and snippets.

@behnamazimi
Created December 27, 2019 11:24
Show Gist options
  • Save behnamazimi/067a4062174177740aece8aedb294632 to your computer and use it in GitHub Desktop.
Save behnamazimi/067a4062174177740aece8aedb294632 to your computer and use it in GitHub Desktop.
const data = {
items: ["A", "B", "C"],
[Symbol.iterator]: function* myIterator() {
this.pointerIndex = 0;
while (this.pointerIndex < this.items.length)
yield this.items[this.pointerIndex++];
}
}
for (let item of data) {
console.log(item)
} //o: A B C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment