Bug: Chrome's for.. In Loop Messes the Order of the Indexes
Yes. I know I should never rely on for..in loop order, but when it comes to inconsistency of browsers it can be annoying.
I found it out when I wanted to fetch the first key of an object, but got different results on chrome (incorrect result) and other browsers.
Code:
1 2 3 4 5 6 7 8 9 10 11 |
|
The Result:
Firefox / Safari / IE:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Chrome:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
As you can see, the second and third loops enumerate on an object with numbers as indexes. What Google Chrome seem to do is treat the object as an Array, which outputs the numeric indexes first, in ascending order.
To me, it looks like a bug that may create inconsistency. Google & Chromium team - please fix it :)