Mismatch between Google Chrome and Firefox

I get different results for this script in Google Chrome (14.0.835.186) and Firefox (6.0.2).

Can someone explain the discrepancy? What is the behavior defined by the specifications?

EDIT . In Firefox, I see [0] , [0, 1] , etc. In Chrome, I see [0, 1, 2, 3, 4] , [0, 1, 2, 3, 4] , [0, 1, 2, 3, 4] , etc.

I am using Mac OS 10.6.8.

+4
source share
3 answers

Cm:

This is a weird behavior or console, although I can’t tell you why.

Edit: Just to make sure this is clear, this is just a β€œbug” in the console, there is no problem with how arrays are created in Chrome.

+3
source

In this case, Firefox is more technically correct, as it displays the state of the object at each point of the loop, while Chrome seems to wait until the end of the loop displays each console.log, but I don’t know the standard specification that covers console host object.

See this jsFiddle: http://jsfiddle.net/jfriend00/LRGP2/ to show that it is only console.log that has this strange behavior.

+3
source

You register a live object .

Try the code below ( fiddle ) and see the difference:

 var i, test = []; for(i=0; i<5; i++) { test.push(i); console.log( test.toString() ); // notice .toString() addition } 

Btw, the same example with exacerbation can be seen in Opera Dragongfly - arrays are even viewable and extensible.

+2
source

All Articles