I have a question about how javascript copies objects with the below sample code:
var blue = {a:1};
var yellow = blue
yellow = 3;
In this case, blue's value would be unaffected as an object with a=1. However, when written like this:
var blue = {a:1};
blue.b = 2;
var yellow = blue
yellow.c = 3;`
in this case, console.log(blue) would show blue also having an extra {c:3} in it's object. How is the variable blue getting affected by yellow when the yellow = blue
should be just yellow referencing blue and not vice versa?