Created
May 14, 2019 08:53
-
-
Save Mayankgupta688/958835939554eee7e6f4ed4bae4f5b80 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
| function* customGenerator() { | |
| yield 1; | |
| yield 2; | |
| yield 3; | |
| } | |
| let getIterator = customGenerator(); | |
| let nextValue = null; | |
| nextValue = getIterator.next(); | |
| console.log(nextValue); | |
| // Output is: { value: 1, done: false } | |
| nextValue = getIterator.next(); | |
| console.log(nextValue); | |
| // Output is: { value: 2, done: false } | |
| nextValue = getIterator.next(); | |
| console.log(nextValue); | |
| // Output is: { value: 3, done: false } | |
| nextValue = getIterator.next(); | |
| console.log(nextValue); | |
| // Output is: { value: undefined, done: true } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment