UPDATE: Check out my last post on the matter: JavaScript Performance: JsPerf.com Myths

This is the second post of a series of posts about javascript performance and loops and I’m going to focus on the several loop options that we have in some of the most popular javascript libraries, namely JQuery and Underscore, and I will compare their performance in front of the classic loops that we tested in my previous post.

As usual, I have prepared a jsperf test for you to check it for your own and compare the results in several browsers.

An important thing to bear in mind is that Underscore ‘each’ implementation will check for the existence of native Array.prototype.forEach. That’s why you will see that its performance value is very similar to native implementations’ time.

In short, in almost any browser, normal loops are faster than JQuery and Underscore libraries so I recommend you to use them if possible. Remember I said ‘almost any browser’ because Internet Explorer 9 is really faster using native array forEach implementation.

I hope you have found this useful.

Test in Chrome