Skip to content

Instantly share code, notes, and snippets.

@vbauerster
Created September 13, 2015 21:56
Show Gist options
  • Save vbauerster/62b3a3bbffe591e17d04 to your computer and use it in GitHub Desktop.
Save vbauerster/62b3a3bbffe591e17d04 to your computer and use it in GitHub Desktop.
function* objectEntries(obj) {
let propKeys = Reflect.ownKeys(obj);
for (let propKey of propKeys) {
yield [propKey, obj[propKey]];
}
}
let jane = { first: 'Jane', last: 'Doe' };
for (let [key, value] of objectEntries(jane)) {
console.log(`${key}: ${value}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment