Created
December 27, 2019 11:22
-
-
Save behnamazimi/be35b5f133e703c991818a0e4f211663 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = { | |
items: ["A", "B", "C"], | |
pointerIndex: 0, | |
next() { | |
if (this.pointerIndex < this.items.length) // if done | |
return { value: this.items[this.pointerIndex++], done: false } | |
else // if not done | |
return { value: undefined, done: true }; | |
} | |
} | |
for(let item of data) { | |
console.log(item); | |
} | |
//o: Uncaught TypeError: data is not iterable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment