array concat vs plus-equals (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
String Concat +=
var html_a = [],
    html_s = '';
html_s += '<div>Div #' + 1 + '</div>';
html_s += '<div>Div #' + 2 + '</div>';
html_s += '<div>Div #' + 3 + '</div>';
html_s += '<div>Div #' + 4 + '</div>';
html_s += '<div>Div #' + 5 + '</div>';
ready
Array Push Multiple
var html_a = [],
    html_s = '';
html_a.push('<div>Div #', 1, '</div>');
html_a.push('<div>Div #', 2, '</div>');
html_a.push('<div>Div #', 3, '</div>');
html_a.push('<div>Div #', 4, '</div>');
html_a.push('<div>Div #', 5, '</div>');
html_s = html_a.join('');
ready
Array Push Single
var html_a = [],
    html_s = '';
html_a.push('<div>Div #');
html_a.push(1);
html_a.push('</div>');
html_a.push('<div>Div #');
html_a.push(2);
html_a.push('</div>');
html_a.push('<div>Div #');
html_a.push(3);
html_a.push('</div>');
html_a.push('<div>Div #');
html_a.push(4);
html_a.push('</div>');
html_a.push('<div>Div #');
html_a.push(5);
html_a.push('</div>');
html_s = html_a.join('');
ready
String Concat x = x + y + z
var html_a = [],
    html_s = '';
html_s = '<div>Div #' + 1 + '</div>' + '<div>Div #' + 2 + '</div>' + '<div>Div #' + 3 + '</div>' + '<div>Div #' + 4 + '</div>' + '<div>Div #' + 5 + '</div>';
ready
Sring Concat x = x + y
var html_a = [],
    html_s = '';
html_s = '<div>Div #' + 1 + '</div>';
html_s = html_s + '<div>Div #' + 2 + '</div>';
html_s = html_s + '<div>Div #' + 3 + '</div>';
html_s = html_s + '<div>Div #' + 4 + '</div>';
html_s = html_s + '<div>Div #' + 5 + '</div>';
ready
String Concat .concat
var html_a = [],
    html_s = '';
html_s = '<div>Div #'.concat(1).concat('</div>');
html_s = html_s.concat('<div>Div #').concat(2).concat('</div>');
html_s = html_s.concat('<div>Div #').concat(3).concat('</div>');
html_s = html_s.concat('<div>Div #').concat(4).concat('</div>');
html_s = html_s.concat('<div>Div #').concat(5).concat('</div>');
ready

Revisions

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