Skip to content

Instantly share code, notes, and snippets.

@cyberpirate92
Created May 14, 2019 13:30
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 cyberpirate92/01d450971a0b825e1cdbed2bfb7a05ca to your computer and use it in GitHub Desktop.
Save cyberpirate92/01d450971a0b825e1cdbed2bfb7a05ca to your computer and use it in GitHub Desktop.
// assigning object to x
x = {
name: 'John',
age: 20
};
y = x;
x.name = 'John Doe';
console.log(y.name); // prints "John Doe"
y === x // true
// assigning new object changes reference
x = {
name: 'John',
age: 20
};
y === x // false, since x's reference has changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment