Possible duplicate:
Is the Chrome JavaScript console lazy about evaluating arrays?
I am trying the following code:
var myList = new Object();
var item = new Object();
item.text = "item-1";
myList[3] = item;
console.log(myList);
console.log(myList[3].text);
var item2 = new Object();
item2.text = "item-2";
myList[3] = item2;
console.log(myList);
console.log(myList[3].text);
The result is pretty odd:
* Object
* 3: Object
text: "item-2"
item-1
* Object
* 3: Object
text: "item-2"
item-2
BUT - if I execute the second part after a while (using setTimeout) and expand the first object, I get it right, that is:
* Object
* 3: Object
text: "item-1"
item-1
* Object
* 3: Object
text: "item-2"
item-2
It is very important for me to share it, since I think that you can spend a lot of time trying to understand what is wrong in its code. And if someone has a link to an open error or something else - answer this ticket. Thank!
source
share