Created
December 10, 2018 08:53
Part 2 Javascript Tip and Tricks Object Rest Paramater
This file contains 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
var greetUsers = users.map(user => { | |
const { name, ...payload } = user // we collect all others key into payload | |
return { | |
...payload, | |
name: `Hello ${name}`, | |
} | |
}) | |
// 👍 more shorter syntax | |
var greetUsers = users.map(({ name, ...payload }) => ({ | |
...payload, | |
name: `Hello ${name}`, | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment