Created
April 27, 2017 19:40
-
-
Save dleitee/8ae62f4b34d75d77142bb952d16b94d0 to your computer and use it in GitHub Desktop.
Mutable Code
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: 'John Due', | |
birthdate: '1988-08-15', | |
} | |
const changeName = (user, newName) => { | |
const newUser = user | |
newUser.name = newName | |
return newUser | |
} | |
const userWithNewName = changeName(user, 'Jojo') | |
// both users will have the name = 'Jojo' | |
console.log(user, userWithNewName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment