-
-
Save asen-ruuby/c288307babb93101512cd3a4e47c75b5 to your computer and use it in GitHub Desktop.
Object entries fix
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
const obj = Object.fromEntries([[Symbol('ok'), 123]]); | |
function getEntries(obj) { | |
const ownKeys = Reflect.ownKeys(obj); | |
const entries = []; | |
for (const key of ownKeys) { | |
if ({}.propertyIsEnumerable.call(obj, key)) { | |
entries.push([key, obj[key]]); | |
} | |
} | |
return entries; | |
} | |
console.log(getEntries(obj)); | |
// [ [ Symbol(ok), 123 ] ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment