I've been loving this series because it gives me the opportunity to really dive into some of these new features.
Today, we're looking at Object.fr...
For further actions, you may consider blocking this person and/or reporting abuse
Great write up & explanation, thank you! One possible typo — in your final code example, you say —
However, in the code example that follows, you have —
... shouldn't that be, on the 2nd line —
const entries = Object.fromEntries(arr)
??Thought you'd want to know. But this is great and I learned a lot from both this and your other guide on for...in (Objects) and for...of (Arrays). Keep up the great work!
Thanks for catching that! I’ll take a look.
Thanks for the writeup! Worth noting this is already in Chrome, Firefox, Node 12 but not Edge:
MDN Object.fromEntries
Without it I have been using reduce to make an object from array of key-value pairs... this will be a lot easier!
To no one's surprise, not Edge.
Definitely worth noting! Thanks for that.
Thank you so much for this article! Learned something new today. I think there may be a typo here:
where you said
Object.forEntries
instead ofObject.fromEntries
.Ah, thank you! Will fix that one.
Oddly enough, what I found most helpful was the example of destructuring array arguments during the map, it's not a pattern I see very often in my to see an array containing arrays, but that syntax will be incredibly helpful.
That's great! Glad it helped. I also have a post all about destructuring.
3 Powerful Examples of Destructuring Assignment
Laurie ・ Jun 11 ・ 2 min read
This is fantastic! No more having to use
.reduce
to convert an array back into an Object. 🎉 I know this isn't yet supported in Edge - is there a polyfill for it?So it looks like it might be supported by Edge? At least according to this.
github.com/feross/fromentries
I think they mean the ponyfill is supported in Edge. But maybe not! The wording is kind of ambiguous there.
Agreed.
Great article. I didn't know we could turn an array into an object with this :)