Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's fairly well-known that Array#forEach is up to an order of magnitude slower than a for-loop, across browsers. The usual reason given is the overhead of invoking a closure from the VM. A JS implementation of forEach ought to be somewhere in the middle.

The speed-up for "concat" is surprising to me. I wonder if it holds for "splice" and if that is true across browsers.



And it can be made even faster ;)

http://jsperf.com/fast-iter




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: