I have this snippet of code :
let a = {};
a.x = 'John';
let b = [];
b['y'] = a;
console.log(b);
a.x = 'Dan';
console.log(b)
I ran this code in NodeJS using command line and ran it in Chrome browser console.
The result : in NodeJS, the result was [ y: { x: 'John' } ] [ y: { x: 'Dan' } ] NodeJS result
The result : in Chrome browser console, the result was : [ y: { x: 'Dan' } ] [ y: { x: 'Dan' } ] Browser result
Why it is giving different results in node and browser console? Can anyone please explain what is really going on here?