for-in VS Array.forEach

Benchmark created on


Setup

var a = [];
    for (var i = 0; i < 10000; i++) { a[i] = i; }

Test runner

Ready to run.

Testing in
TestOps/sec
for-in
// async test
for (i in a) {
Math.pow(2, a[i]);
}
ready
Array.forEach
// async test
a.forEach(function(i, v){
Math.pow(2, v);
});
ready

Revisions

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