Created
May 14, 2019 13:30
-
-
Save cyberpirate92/01d450971a0b825e1cdbed2bfb7a05ca to your computer and use it in GitHub Desktop.
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
// 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