forEach vs. jQuery .each

Benchmark created by Andreas Goebel on


Description

This test compares speeds from ECMAscript5 (262) Array.prototype.forEach vs jQuery .each method

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var arr = [],
      loop = 5000;
  
  while (loop--) {
   arr[loop] = loop;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
each()
$.each(arr, function(i, v) {
 v = v;
});
ready
forEach()
arr.forEach(function(v, i) {
 v = v;
});
ready

Revisions

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