function StringBuffer() { this.buffer = []; } StringBuffer.prototype.append = function(string) { this.buffer.push(string); return this; } StringBuffer.prototype.toString = function() { return this.buffer.join(""); }Usage: var s = new StringBuffer(); s.append("Hello, ").append(" World!"); alert(s.toString());
You are here: Home > javascript > JavaScript StringBuffer like java StringBuffer object