Append string vs join array (v28)

Revision 28 of this benchmark created on


Preparation HTML

<script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<div id="fox"></div>

Setup

var i = 0, str = '', arr = [],
    w1 = 'brown', w2 = 'jumped', w3 = 'lazy';
    var element = $('#fox');

Teardown


    $('#fox').empty();
  

Test runner

Ready to run.

Testing in
TestOps/sec
String append #1
'Quick ' + w1 + 
' fox ' + w2 + 
' over the ' + w3 + 
' dog. ';
ready
String append #2
element.append('Quick ' + w1 + ' fox ' + w2 + ' over the ' + w3 + ' dog. ');
ready
Array join #1
['Quick ', w1, 
' fox ', w2, 
' over the ', w3, 
' dog. '].join('');
ready
Array join #2
element.text('Quick ' + w1 + ' fox ' + w2 + ' over the ' + w3 + ' dog. ').text;
ready

Revisions

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