For vs Foreach

JavaScript performance comparison

Test case created by asdf

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Foreach
var count = 1000000;
map = {};
apps = [];

for (_i = 0, _len = count; _i < _len; _i++) {
  apps.push({name:'test', sss:'X'});
}

apps.forEach(function(app) {
  map[app.name] = app;
});
 
pending…
For
var count = 1000000;
map = {};
apps = [];

for (_i = 0, _len = count; _i < _len; _i++) {
  apps.push({name:'test', sss:'X'});
}

for (_i = 0, _len = apps.length; _i < _len; _i++) {
  app = apps[_i];
  map[app.name] = app;
}
 
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