Array Iteration Test

JavaScript performance comparison

Test case created by Sam Skjonsberg

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var items = [1,2,3,4,5,6,7,8,9,10];
};
</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 with len
var i, ii;
for(i = 0, ii = items.length; i < ii; i++) {}
pending…
forEach
items.forEach(function(){});
pending…
For no len
var i;
for(i = 0; i < items.length; i++) {}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment