Created
February 12, 2017 14:27
-
-
Save TCotton/9b6f4f62e121f02fcabe29788f3002a7 to your computer and use it in GitHub Desktop.
find object values and arrays -> shallow object
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* objectEntries(obj, findKeys = false) { | |
let keys = Reflect.ownKeys(obj); | |
if(findKeys) { | |
yield keys; | |
} else { | |
for (let key of keys) { | |
yield [key, obj[key]]; | |
} | |
} | |
} | |
objectEntries({one: 'this is a string', two: 'this is another string'}, true).next(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment