Skip to content

Instantly share code, notes, and snippets.

@asen-ruuby
Created July 25, 2022 16:22
Show Gist options
  • Save asen-ruuby/c288307babb93101512cd3a4e47c75b5 to your computer and use it in GitHub Desktop.
Save asen-ruuby/c288307babb93101512cd3a4e47c75b5 to your computer and use it in GitHub Desktop.
Object entries fix
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