Created
January 8, 2020 22:52
-
-
Save luchiago/0f98573b18662df5741d699c5b1ff7d3 to your computer and use it in GitHub Desktop.
An use of spread operator in JavaScript
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
const user = { | |
name: 'Lucas', | |
lastName: 'Hiago' | |
}; | |
function getUserWithFullName(user) { | |
return { | |
...user, //spead operator | |
fullName: `${user.name} ${user.lastName}` | |
} | |
} | |
const userWithFullName = getUserWithFullName(user); | |
console.log(userWithFullName, user); | |
// output: Lucas Hiago |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment