Yep, that's nice. Object.keys(obj) always bothered me as then you needed to grab the value from the obj with the index of the key, but this way you have it there when you map etc.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice :0) I had heard of freeze recently. What would you do with the output of entries though?
P.s. typo in the last eg should be
const ponyB = ponyA
entries
andfromEntries
are awesome because they allows you to useArray.prototype.filter, map, reduce
with objects (and their keys too!)Use them to mutate and create objects from existing objects.
For example:
and now thanks to
fromEntries
you can do the same withoutreduce
:Typo fixed! Thanks for the heads-up!
As for the output of entries, I think I shall refer to the others' replies :D
It's quite useful to convert objects to other formats, like query strings or SQL queries:
Yep, that's nice.
Object.keys(obj)
always bothered me as then you needed to grab the value from the obj with the index of the key, but this way you have it there when you map etc.