Possible Duplicate:
Is Chrome's JavaScript console lazy about evaluating arrays?
Chrome’s js console is showing an array with a deleted value before the value is deleted. Why?
jsFiddle that demonstrates this behavior.
var list=[];
list.push("one");
list.push("two");
list.push("three");
console.log(list); //["two", "three", undefined × 1]
$("#output").append(JSON.stringify(list));//["one","two","three"]
list.shift();
$("#output").append($("<br>"));
console.log(list); //["two", "three"]
$("#output").append(JSON.stringify(list));//["two","three"]
In Chrome
console.logis "delayed"; in this case to the end of the Program I believe.That is, in Chrome,
console.logdoes not stringify the input object immediately but rather performs the stringification "some time later" (after which the object has been modified in this case) but before it actually displays the result,console.log(JSON.stringify(list))would show the expected result.This was reported as a bug as far back as Chrome 5 (the bug-fix target is Mstone-22, so not Chrome 20/21?) and a fix has been added to the webkit base: