原生JS实现StringBuffer
文章目录
function StringBuffer(str) {
this.__strings__ = [str];
return this;
}
StringBuffer.prototype = {
constructor: StringBuffer,
append: function (str) {
this.__strings__.push(str);
return this;
},
clear: function () {
this.__strings__ = [];
},
toString: function () {
return this.__strings__.join('');
}
};
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论