Home >Web Front-end >JS Tutorial >js efficient string assembly StringBuffer_javascript tips

js efficient string assembly StringBuffer_javascript tips

WBOY
WBOYOriginal
2016-05-16 18:38:331456browse

function StringBuffer() {
this.array = new Array();
}

StringBuffer.prototype.append = function(value) {
this.array[this.array.length] = value;
return this;
}

StringBuffer.prototype.toString = function() {
var _string = this.array.join("");
return _string;
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn