map(fn) vs map(arrow) vs fori

JavaScript performance comparison

Revision 2 of this test case created by Stefan Penner

Preparation code

Benchmark.prototype.setup = function() {
  function square(x) {
    return x * x;
  let values = new Array(100).map((x, i) => i);


Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
fori + push
let result = self.result = [];
for (let i=0; i<values.length; ++i) {
  result.push(i * i);

self.result = result;


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