Skip to content

Instantly share code, notes, and snippets.

@splincode
Last active May 25, 2019 13:36
Show Gist options
  • Save splincode/f1425233b115e0aeb6519664cdf1c72c to your computer and use it in GitHub Desktop.
Save splincode/f1425233b115e0aeb6519664cdf1c72c to your computer and use it in GitHub Desktop.
/*
You have to understand that each object
has a unique identity in JavaScript
console.log(new Object() === new Object());
*/
console.log({} === {}); // false
/*
But when you assign `fiz` to `baz`, `baz` points to the same object as `fiz`.
Since `fiz` and `baz` are the same thing, when you change `baz`, `fiz` reflects the same change.
*/
const fiz = { foo: 'bar' };
const baz = fiz;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment