javascript for-loop vs jQuery each() over an array of 50 elements (v3)

Revision 3 of this benchmark created by David Tong on


Description

Javascript for(each) vs jQuery (for)each.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var obj = ['test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7', 'test8', 'test9', 'test10', 'test11', 'test12', 'test13', 'test14', 'test15', 'test16', 'test17', 'test18', 'test19', 'test20', 'test21', 'test22', 'test23', 'test24', 'test25', 'test26', 'test27', 'test28', 'test29', 'test30', 'test31', 'test32', 'test33', 'test34', 'test35', 'test36', 'test37', 'test38', 'test39', 'test40', 'test41', 'test42', 'test43', 'test44', 'test45', 'test46', 'test47', 'test48', 'test49', 'test50']
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Javascript for loop
for (var i = 0; i < obj.length; i++) {
  if (obj[0]) {
    window[obj[0]];
  }
}
ready
jQuery.each()
$.each(obj, function(i, name) {
  if (name) {
    window[name];
  }
});
ready

Revisions

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