In the development use StringBuilder as far as possible and not everyone will pay attention to in using common way of string concatenation. But perhaps most of the developers ignore the js also need to pay attention to the efficiency problem.
the following on a performance test, using fact to speak!

function xntest () {
var d1=new Date ();
var STR="";
the for (var I=0; i<10000; i++) {
STR +="stext";
var d2=new Date ();
document. Write (" string concatenation method time-consuming: "+ (d2) getTime () - d1. GetTime ()) +" millisecond; ");
d1=new Date ();
var sb=new StringBuilder ();
the for (var I=0; i<10000; i++) {
sb. Append (" stext ");
var result=sb. The toString ();
d2=new Date ();
document. Write (" array pattern time: "+ (d2) getTime () - d1. GetTime ()) +" millisecond; ");
/////using an Array of string concatenation function, for the convenience of the c #developer specially named StringBuilde understand
in order to facilitate the function StringBuilder () {
this. _strings_=new Array;

} StringBuilder) prototype. Append=function (STR) {
this. _strings_. Push (STR);
the StringBuilder. Prototype. ToString=function () {
return this. _strings_. Join (" ");

three executive xntest () function is the result of the:

string concatenation method time-consuming: 735 milliseconds. Array way time-consuming: 62 milliseconds.
string concatenation method time-consuming: 766 milliseconds. Array way time-consuming: 63 milliseconds.
string concatenation method time-consuming: 703 milliseconds. Array way time-consuming: 63 milliseconds.

this is joining together 10000 string performance test, believe the results to everyone, interested friends can test ourselves.
so, we should also try to avoid in the front desk development of large-scale string concatenation operation, the array should be adopted reasonable way to improve the efficiency of the code.

you might be interested in the article:

  • JS efficient assembled under several methods of string comparison with test code
  • high performance under the javascript string concatenation StringBuffer class
  • javascript string substitution function in the replace () method is a little different with c #, vb to replace
  • javascript trim removal string Spaces of three methods (with the code, rounding)
  • javascript string as a dom object (string dynamically create dom)
  • is inserted into the string at the cursor implementation code compatible with Internet explorer, Firefox
  • javascript string manipulation of several common methods
  • the Fastest way to build an HTML string (HTML string assembled the Fastest method)

This concludes the body part