Array.flat

JavaScript performance comparison

Test case created by vkiperman

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var hours = [
      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
      [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
      [20, 21, 22, 23],
      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
      [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
      [20, 21, 22, 23]
  ]

};
</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
flat()
var flatHours = hours.flat();
pending…
concat.apply()
var flatHours = [].concat.apply([], hours);
pending…
reduce()
hours.reduce((acc, val) => acc.concat(val), [])
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