Array.from vs Array.fill+map

JavaScript performance comparison

Test case created by edwjusti

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const mapFn = () => ({});

};
</script>

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
Array.from
const arr = Array.from({
  length: 100
}, mapFn);
pending…
Array.fill
const arr = Array(100).fill().map(mapFn);
pending…
for loop
const arr = [];
for (let index = 0; index++ < 100;) {
  arr.push(mapFn());
}
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.

0 Comments