Posts Tagged ‘ie’
Links^2 – July 22th, 2010
Thursday, July 22nd, 2010- Def.js – Simple Ruby-style inheritance for JavaScript. The use of “<<” operator with “valueOf” for inheritance is very creative.
- CSS3 Pie – Makes Internet Explorer 6-8 capable of rendering several of the most useful CSS3 decoration features.
- There’s a class for this - Advanced MooTools Class tutorial.
- Microsoft WebMatrix – Microsoft’s new IDE for rapid web development, using the new Razor Engine (.cshtml). Looks good at first sight.
- 10 Things I Learned from the jQuery Source – Advanced JavaScript screencast. Worth the ~54 minutes.
- HTML5 Essentials Slideshow – More on the HTML5′s new features.
- CSS3 Slideshow
Bug: Chrome’s for..in Loop Messes the Order of the Indexes
Tuesday, July 13th, 2010Yes. 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:
console.log("wordsAsKeys");
var wordsAsKeys={ words:"value",as:"value",keys:"value" };
for (var k in wordsAsKeys) console.log(k);
console.log("numbersAsKeys");
var numbersAsKeys={ "3":"value","2":"value","1":"value" };
for (var k in numbersAsKeys) console.log(k);
console.log("mixedKeys");
var mixedKeys={ "3":"value",words:"value","1":"value" };
for (var k in mixedKeys) console.log(k);
The Result:
Firefox / Safari / IE:
wordsAsKeys words as keys numbersAsKeys 3 2 1 mixedKeys 3 words 1
Chrome:
wordsAsKeys words as keys numbersAsKeys 1 2 3 mixedKeys 1 3 words
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 :)