for-in vs jquery each - json iteration

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  function bar(key, val) {};
  var a = {
    'k1': 'v1',
    'k2': 'v2',
    'k3': 'v3'
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
for-in
for (var i in a) {
  if (a.hasOwnProperty(i)) {
    bar(i, a['i']);
  }
}
ready
jQuery-each
jQuery.each(a, function(i, val) {
  bar(i, val);
});
ready

Revisions

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