javascript에서 StringBuffer 사용하기.

웹 & 안드로이드/HTML5|2013. 10. 13. 18:33
<script>
var StringBuffer = function() {
    this.buffer = new Array();
};
StringBuffer.prototype.append = function(str) {
    this.buffer[this.buffer.length] = str;
};
StringBuffer.prototype.toString = function() {
    return this.buffer.join("");
};
</script>

<script>
var tag = new StringBuffer();
tag.append('ABC');
tag.append('DFG');
var text = tag.toString();
</script>

댓글()