Created
November 15, 2017 18:46
-
-
Save bbaaxx/187d4eb1d2b0894f4d414a00acb30b6c to your computer and use it in GitHub Desktop.
Code for blog post about iterators iterables and generators with ES6
This file contains 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
someObject[Symbol.iterator] = function* someObjectIterator() { | |
for (let prop of Object.keys(this)) { | |
yield this[prop]; | |
} | |
}; | |
console.log([...someObject]) // [1, "Yolodog", "a"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment