Created
March 25, 2016 22:09
-
-
Save monners/845aff42a00e474fff31 to your computer and use it in GitHub Desktop.
Utility function for making Objects iterable
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
function makeObjectIterable (obj) { | |
obj[Symbol.iterator] = function *() { | |
let properties = Object.keys(this); | |
for (let p of properties) { | |
yield this[p]; | |
} | |
} | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment