Chrome 28.0.1500.71 on OS X 10.8.4 (map is 54% slower)
Safari 6.0.5 on OS X 10.8.4 (map is 28% slower)
Firefox 23.0 on OS X 10.8.4 (map is 62% slower)*
Opera 12.16 on OS X 10.8.4 (map is 72% slower)
IE 10.0 on Windows 7 [via VirtualBox] (map is 42% slower)
And testing the same via a node.js benchmark it says the fastest is comprehension. https://gist.github.com/Kerrick/cff3d1212c82bc804712
* Every time I load the JSPerf page on Firefox, the first run the two tests are on par, and the second (and following) runs I get map being much slower. I have to wonder if the JS engine begins optimizing the comprehension version at some point.
I write a lot of games and game related things in JavaScript, and this is actually a major reason why I now use CoffeeScript. Nice clean comprehension syntax and better performance.
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
I don't ever advise using map, but you can't setup your own for loop in coffeescript. Actually, in the code shown, map isn't used at all. Just .filter and .forEach.
Here is my version: http://jsperf.com/no-coffeescript-orig
The 'manual' is what I would write myself.
Firefox nightly produces an interesting test run: http://cl.ly/image/2s0p1Y3E2Z0C not really sure why that happens.