News for hackers. Stuff that matters.
Re:Deep-copying in JavaScript by n0us on Thursday January 25, 2018 @02:52PM (#16233993)
Another way to think about it is that you just get a new reference to the same object, inside foo you are changing what 'a' refers to instead of what 'b' refers to. Using 'let' to declare 'b' is not necessary and using 'const' works just as well.

$ node

> const b = { bar: 'baz' }

> function foo(a){ a = {beep: 'boop'}; }

> foo(b)

> console.log(b)

{ bar: 'baz' }

>

There are no comments on this comment yet.