The strings are Javascript connections

The first: with the connector "+" connection string

str="a";
str+="b";

This method is relatively two, the most convenient and fast. 100 characters or less is recommended to connect using this connection.

The second: an array as an intermediary, the connection function used jion

var arr=new Array();
arr.push(a);
arr.push(b);
var str=arr.join("");

Third: the connection object attribute string using

function stringConnect(){
    this._str_=new Array();
}
stringConnect.prototype.append=function(a){
    this._str_.push(a);
}
stringConnect.prototype.toString=function(){
    return this._str_.join();
}
    var mystr=new stringConnect;
    mystr.append("a");
    var str=mystr.toString();

  

Guess you like

Origin www.cnblogs.com/miaolyou/p/10936114.html