Spread operator-head-vs-tail

JavaScript performance comparison

Revision 5 of this test case created by Dmitri Pavlutin

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const numbers = Array.from(Array(10000), (_, i) => i + 1);

};
</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, item]
function appendToTail(item, array) {
  return [...array, item];
}

appendToTail(1, numbers);
appendToTail(2, numbers);
appendToTail(3, numbers);
pending…
[item, ...array]
function appendToHead(item, array) {
  return [item, ...array];
}

appendToHead(1, numbers);
appendToHead(2, numbers);
appendToHead(3, numbers);
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