lograr:
function stringBuffer () {this .__ Strings__ = []; }; StringBuffer.Prototype.append = function (str) {this .__ Strings __. Push (str); devolver esto; }; // Format String StringBuffer.Prototype.appendFormat = function (str) {for (var i = 1; i <arguments.length; i ++) {var parent = "// {" + (i - 1) + "//}"; var reg = new Regexp (Parent, "G") str = str.replace (reg, argumentos [i]); } this .__ Strings __. Push (str); devolver esto; } StringBuffer.Prototype.ToString = function () {return this .__ Strings __. Join (''); }; StringBuffer.Prototype.Clear = function () {this .__ Strings__ = []; } StringBuffer.prototype.size = function () {return this .__ Strings __. Longitud; }Llamadas instanciadas
var sbhtml = new StringBuffer (); sbhtml.append ('hola'); sbhtml.append ('mundo'); console.log (sbhtml.ToString ());El ejemplo simple anterior de la implementación de JS StringBuffer es todo el contenido que comparto con usted. Espero que pueda darle una referencia y espero que pueda apoyar más a Wulin.com.