Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50
Safari 10
Mac OS X 10.12
Other
8 years ago
Test name Executions per second
jQuery.each 685103.1 Ops/sec
Array.prototype.forEach 540880.0 Ops/sec
traditional for loop 189162.2 Ops/sec
Script Preparation code:
AخA
 
var arr = ['torus', 'gospel', 'bacon', 'moist', 'lodge', 'flip', 'ev', 'usual', 'glans', 'lanka', 'ames', 'stoic', 'weco', 'buff', 'naacp', 'mercy', 'stork', 'rq', 'mace', '37', 'rung', 'shod', 'snap', 'pr', 'horus', 'lane', 'safe', 'tie', 'yeasty', 'topple', 'grist', 'coed', 'sled', 'bosom', 'packet', 'xn', 'bunch', 'rowdy', 'jo', 'prone', 'styli', 'warmth', 'jimmy', 'launch', 'aspire', 'roil', 'ohm', 'doff', 'slice', 'dream', 'roger', 'theme', 'lz', 'minus', 'lusty', '35th', 'acuity', 'eli', 'spool', 'pivot'];
Tests:
  • jQuery.each

     
    var temp;
    $.each(arr, function(index, item) {
      temp = item;
    });
  • Array.prototype.forEach

     
    var temp;
    arr.forEach(function(item) {
      temp = item;
    });
  • traditional for loop

     
    var temp;
    for (var i = 0, len = arr.length; i !== len; ++i) {
      temp = arr[i];
    }