concat arrays

Benchmark created by V1 on


Description

There are different ways of adding concat arrays. You can use array.concat or leverage the Array.prototype methods.

So, what will be faster? Array.concat because, it's build for it.. Or a prototype function?

Preparation HTML

<script>
  var arr1 = [];
  var arr2 = [];
  var arr3 = [];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
concat
arr1 = arr1.concat(new Array(100));
ready
Array prototype push
Array.prototype.push.apply(arr2, new Array(100))
ready
Array prototype unshift
Array.prototype.unshift.apply(arr3, new Array(100))
ready

Revisions

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

  • Revision 1: published by V1 on
  • Revision 4: published by V1 on
  • Revision 5: published by Leonardo Dutra on
  • Revision 6: published by Leonardo Dutra on
  • Revision 7: published by Denis G. on