I was given a short javascript code in an interview to give the output of that but I was not sure what will be the output of that. He creates a var object
and assigns objects as indexes of that object using the array data structure. I did console that code after the interview but still do not understand how it is showing the output.
Here is the code
var a = {};
b = { key: 'b'};
c = { key: 'c'};
a[b] = 123;
a[c] = 456;
console.log(a[b]); //what is the output of this console statement and explain why
Can anyone explain with javascript logic behind the output it shows? Thanks in advance!