Skip to content

Instantly share code, notes, and snippets.

@dleitee
Created April 27, 2017 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dleitee/8ae62f4b34d75d77142bb952d16b94d0 to your computer and use it in GitHub Desktop.
Save dleitee/8ae62f4b34d75d77142bb952d16b94d0 to your computer and use it in GitHub Desktop.
Mutable Code
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