jQuery.each vs _.each vs for loop (v28)

Revision 28 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.min.js"></script>
<script>
  var lodash = _.noConflict();
  var array = $('*').get();
</script>

Setup

var $ = window.$;
    var _ = window._;
    var lodash = window.lodash;
    
    var e;
    var array = window.array;

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.each
$.each(array, function(index, element) { e = element; })
ready
_.each (underscore)
_.each(array, function(element, index, list) { e = element; });
ready
_.each (lodash)
lodash.each(array, function(element, index, list) { e = element; });
ready
for loop
for (var i = 0, len = array.length; i < len; i++) { e = array[i]; }
ready
while loop
var i = 0;
while(i < array.length){ e = array[i]; i++;}
ready

Revisions

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