After 20 iterations:
Browser Pre-alloc No pre-alloc
Firefox 3.6.13 OSX 824ms 829ms
Safari 5.0.3 OSX 812ms 948ms
Chrome 9.0.597.16 OSX 1317ms 992ms
I'm pretty sure that in modern browsers new Array(length) doesn't allocate anything, it just sets the length property. The results I'm seeing would agree with Google really.Perhaps you were seeing GC events slowing down the test?
The other thing about for(var i=0;i<arr.length;i++) is it can end up as an infinite loop if you're modifying the length inside the for loop:
for (var i=0;i<arr.length;i++) {
arr[10 + i*2] = "foo";
}
// Infinite loop.Perhaps. Or perhaps it varies by array size?
"Perhaps the most important thing these libraries do is make sophisticated vector graphics possible in Internet Explorer, where JavaScript performance is relatively poor."
Well, yes. Sure, suit yourself, but I think that most modern browsers come with something called a JS code profiler/optimizer and JIT code (FF new JS engine and Chrome surely do, others probably too).
Not to mention that Closure comes with it's own code optimizer that does this for the border cases.
For sanities sake, please don't start to preach that we should do the work of a compiler and bend the code in that direction. Humans are bad at that, and it makes the code unmaintainable.
There are some valid points in the article though, I admit, some pitfalls that might screw up when multiple JS frameworks are running (namespace issues) mostly.
As it happens, I had occasion to test this a few months ago.
On my machine, noPreallocate is 4% faster in FF, but it's 15% slower in IE8 and a whopping 70% slower in Chrome.