Skip to content

Instantly share code, notes, and snippets.

@bbaaxx
Created November 15, 2017 18:46
Show Gist options
  • Save bbaaxx/187d4eb1d2b0894f4d414a00acb30b6c to your computer and use it in GitHub Desktop.
Save bbaaxx/187d4eb1d2b0894f4d414a00acb30b6c to your computer and use it in GitHub Desktop.
Code for blog post about iterators iterables and generators with ES6
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