Last active
June 24, 2019 15:17
-
-
Save projektorius96/7d59f7fea7a6965ef06d1bfaf7ed2cbd 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
| var NumbersToOne = { | |
| [Symbol.iterator]: ()=> { | |
| var i = 10; | |
| return { | |
| prev: ()=> { | |
| if (i > 0) {return { value: i--, done: false };} | |
| else if (i == 0) {{return { value: i--, done: true };} | |
| } | |
| } | |
| }; | |
| } | |
| }; | |
| const doIteration = NumbersToOne[Symbol.iterator](); | |
| doIteration.prev(); // value: 10, done: false | |
| // ... | |
| doIteration.prev(); // value: 0, done: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment