3 ms·
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
by n0us 9y ago
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' }
>