Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active December 20, 2021 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NyaGarcia/2ca5a41746c6cd93f4c10065b0e08581 to your computer and use it in GitHub Desktop.
Save NyaGarcia/2ca5a41746c6cd93f4c10065b0e08581 to your computer and use it in GitHub Desktop.
An example of object mutation in JS
const mySquirtle = {
name: 'Squirtle',
type: 'Water',
hp: 100
};
const anotherSquirtle = mySquirtle;
anotherSquirtle.hp = 0;
console.log(mySquirtle); //Result: { name: 'Squirtle', type: 'Water', hp: 0 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment