Arrays jQuery.merge vs concat

JavaScript performance comparison

Test case created by Jeremy Mullinax-Hill


Merge creates a smaller footprint because it loops through the original array and adds the new items. Concat is a built-in Javascript function and should be faster, but has a larger footprint.

Preparation code

<script src=""></script>
  //unmodified array
  var baseArray = ["Napoleon"];
  //modified arrays
  var catArray = merArray = [];
  //cache concat prototype for best performance
  var concat = Array.prototype.concat;

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
catArray =, baseArray);
$.merge(merArray, baseArray);

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

1 comment

Yanick Rochon commented :

The merge test breaks the browser. I think it concats the arrays too much...

Comment form temporarily disabled.

Add a comment