for, for, for

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var testArray = [];
    for (i = 0; i < 10000; i++) {
      testArray.push(i);
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
for...loop
for (i = 0; i < testArray.length; i++) {
  var a = testArray[i];
}
pending…
for...loop with var
var testArrayLength = testArray.length;
for (i = 0; i < testArrayLength; i++) {
  var a = testArray[i];
}
pending…
for...in
for (i in testArray) {
  var a = testArray[i];
}
pending…

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

Compare results of other browsers

0 comments

Add a comment