Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
I definitely have mixed feelings about this paradigm. I absolutely see the value in quickly mapping from one object to another, but I agree that Object.fromEntries(Object.entries(obj).map(...)) is not the most readable thing.
On the one hand, I sort of expect that it will become a paradigm that is so ubiquitous that everyone will just get used to seeing it and immediately recognize what it's doing, so readability will become less of a problem over time. But on the other hand, if it is going to become that common of an operation, I sort of wish there was a built-in method for it, something like Object.mapEntries(([key, val]) => [key, val+1]), that just did it all in one go.
All that said, it does become a little more readable when split onto a few lines:
I definitely have mixed feelings about this paradigm. I absolutely see the value in quickly mapping from one object to another, but I agree that
Object.fromEntries(Object.entries(obj).map(...))
is not the most readable thing.On the one hand, I sort of expect that it will become a paradigm that is so ubiquitous that everyone will just get used to seeing it and immediately recognize what it's doing, so readability will become less of a problem over time. But on the other hand, if it is going to become that common of an operation, I sort of wish there was a built-in method for it, something like
Object.mapEntries(([key, val]) => [key, val+1])
, that just did it all in one go.All that said, it does become a little more readable when split onto a few lines:
We need Object.mapEntries then I think!