Sparse Iteration (v2)

Revision 2 of this benchmark created on


Setup

var array = [];
    array[10] = 1;
    array[100] = 1;
    array[1000] = 1;
    array[10000] = 1;
    array[100000] = 1;

Test runner

Ready to run.

Testing in
TestOps/sec
for loop
var result = null;
for (var i = 0, l = array.length; i < l; i++) {
  if (i in array) result = array[i];
}
ready
for key in obj loop
var result = null;
for (var i in array) {
  if(array.hasOwnProperty(i))
      result = array[i];
}
ready

Revisions

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