Skip to content

Instantly share code, notes, and snippets.

@rileysparsons
Last active September 5, 2019 21:46
Show Gist options
  • Save rileysparsons/8ad34563a878dd0034883b29a4624c39 to your computer and use it in GitHub Desktop.
Save rileysparsons/8ad34563a878dd0034883b29a4624c39 to your computer and use it in GitHub Desktop.
> const a = {'id': 1, 'status': 3};
> const b = {'id': 2, 'status': '4'};
> const c = {'id': 500, 'foo': a};
> c
{ id: 500, foo: { id: 1, status: 3 } }
> a.status = 33;
33
> c
{ id: 500, foo: { id: 1, status: 33 } }
> const aCopy = c.foo;
undefined
> aCopy
{ id: 1, status: 33 }
> a.status = 44;
44
> aCopy
{ id: 1, status: 44 }
> c
{ id: 500, foo: { id: 1, status: 44 } }
> c.foo = b;
{ id: 2, status: '4' }
> c
{ id: 500, foo: { id: 2, status: '4' } }
> aCopy
{ id: 1, status: 44 }
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment