Created
March 16, 2018 14:49
-
-
Save nesk/41ac3180b83c1cd62f39e57dce6ffa6c to your computer and use it in GitHub Desktop.
Mapping objects in JavaScript (Object.fromEntries + pipeline operator)
This file contains hidden or 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 data = { | |
a: 1, | |
b: 2, | |
}; | |
const newData = Object.entries(data) | |
.map(([key, value]) => ({ [`_${key}`]: value + 1 })) | |
|> Object.fromEntries; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment