js for vs jquery each

Benchmark created by Tóth Zoltán on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var foo = new Array();
    foo[0] = 'egy';
    foo[1] = 'ketto';
    foo[2] = 'harom';

Test runner

Ready to run.

Testing in
TestOps/sec
jquery each
$.each(foo, function(index, value) {
  value.test = 1;
});
ready
js for
var lng = foo.length;
for (var i = 0; i < lng; i++) {
  foo[i].test = 1;
}
ready

Revisions

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

  • Revision 1: published by Tóth Zoltán on