I've got the following code:
$(document).ready(function(){
var array = [{"x": 0}];
array[0] = {"x": 10};
console.log(array);
array[0] = {"x": 20};
console.log(array);
});
With this I expect the output in the console to be:
[
{
0: {"x": 10}
}
]
[
{
0: {"x": 20}
}
]
But instead it is:
[
{
0: {"x": 20}
}
]
[
{
0: {"x": 20}
}
]
Does anyone have any idea why? Am I missing something?
JSFiddle: https://jsfiddle.net/6nfdmt91/