Underscore.each vs jQuery.each vs. Array.forEach (v292)

Revision 292 of this benchmark created by Jeff on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</script>
<script src="//documentcloud.github.com/underscore/underscore-min.js">
</script>
<script>
  var pi = Math.PI
  var a = new Array(1000000),
      e;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.each
$.each(a, function(value,index) {
  e = pi;
});
ready
underscore.each
_.each(a, function(value,index) {
  e = pi;
});
ready
forEach
a.forEach(function(value,index) {
  e = pi;
})
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.