1

I am getting inconsistent results across browsers with this code:

var A = [];
var B = [{}];

console.log(A);
console.log(B);

for(var i = 0;i<5;i++){
    A[i] = "A";
    B[i] = "B";
};

Chrome (reload page with console open):

[]
[Object]
0: "B"
1: "B"
2: "B"
3: "B"
4: "B"
length: 5
__proto__: Array[0]

Firefox:

Array [ "A", "A", "A", "A", "A" ]
Array [ "B", "B", "B", "B", "B" ]

IE 11:

[] - length 0
[object Object] - length 1

The expected behavior is IE one. Can anyone shed some light?

Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66
  • That's just the debugger updating the object contents as the program continues. They don't stay static in Chrome/FF. – Evan Trimboli Jul 01 '14 at 03:45
  • Just saying, I entered the code in Chromium console and got the Firefox behaviour. *Version 33.0.1750.152 Ubuntu 12.04 (256984)* – icedwater Jul 01 '14 at 03:46
  • 2
    Both Firefox and Chrome are showing the proper results, kind-of. You have to understand that the `console` interface isn't necessarily synchronous. – Pointy Jul 01 '14 at 03:47
  • Ah, i think you are right. Thanks. can be closed as duplicate. – user3792322 Jul 01 '14 at 03:52

0 Answers0