javaScriptの実現StrigBuffer
762 ワード
<html>
<script>
function StringBuffer(){
this.string = new Array; // Array
}
StringBuffer.prototype.append = function(str){ // str
this.string .push(str);
}
StringBuffer.prototype.toString = function(){ // join
this.string.join("");
}
var oBuffer = new StringBuffer();
d1 = new Date();
for (var i=0; i < 10000; i++) {
oBuffer.append("text");
}
var sResult = oBuffer.toString();
d2 = new Date();
document.write(d2.getTime()-d1.getTime());
</script>
<body>
</body>
</html>