Arrays and spread operator

Benchmark created by pouya-eghbali on


Setup

var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  var b = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
  var c;

Test runner

Ready to run.

Testing in
TestOps/sec
Merge using spreads
c = [...a, ...b]
ready
Merge using loops
c = []

for (var i = 0; i < a.length; i++) {
  c.push(a[i])
}
for (var i = 0; i < b.length; i++) {
  c.push(b[i])
}
ready
Merge using concat
c = [].concat(a, b);
ready

Revisions

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

  • Revision 1: published by pouya-eghbali on