jQuery each this vs arg

Benchmark created by Nazin on


Preparation HTML

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

Setup

var randoms = [];
    for (var i = 0; i < 100; i++) {
      randoms.push(Math.random())
    }

Test runner

Ready to run.

Testing in
TestOps/sec
each this
$.each(randoms, function() {
  var a = this * this;
});
ready
each arg
$.each(randoms, function(i, val) {
  var a = val * val;
});
ready

Revisions

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

  • Revision 1: published by Nazin on