flatMap vs map & flat

JavaScript performance comparison

Test case created by 子兎音

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  // Array of 0 to 999999
  const numbers = [...Array(1000000).keys()];

};
</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
flatMap
numbers.flatMap(number => [number]);
pending…
map & flat
numbers.map(number => [number]).flat();
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