Let us consider the following JavaScript snippet
var arr = [];
function pushMe()
{
var temp = { "name": "me" };
arr.push(temp)
console.log(arr)
temp["name"] = "you";
arr.push(temp)
console.log(arr)
}
I was astonished to see the output as [Object { name="you"},Object { name="you"}]
As we are pushing the references, both must refer to same object. But at least after the first push output must be like Object { name="me"}
Why is this happening??
thanks :)
[Object { name="me"}]in Firefox, as expected.