Skip to content

Instantly share code, notes, and snippets.

@TCotton
Created September 21, 2015 18:24
Show Gist options
  • Select an option

  • Save TCotton/155e18ea58397a5ff105 to your computer and use it in GitHub Desktop.

Select an option

Save TCotton/155e18ea58397a5ff105 to your computer and use it in GitHub Desktop.
Plain objects are not iterable in ES6—that would clash with iterability of data structures. Helper is easy to write.
//Plain objects are not iterable in ES6—that would clash with iterability of data structures. Helper is easy to write.
function* objectEntries(obj) {
let keys = Reflect.ownKeys(obj);
for (let key of keys) {
yield [key, obj[key]];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment