JavaScript development tools collection (b)
Description:
This method is a Java class in a StringBuffer to imitate, not the efficiency of Java could, but for string assembly, but is a good tool to approach
//StringBuffer工具方法 //数组方式 拼接字符串 .高效... 使用前先实例化. function StringBuffer(){ this._aStr = []; } StringBuffer.prototype.add = function(str){ this._aStr.push(str); return this; } StringBuffer.prototype.toString = function(){ return this._aStr.join(''); }
Use are as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> //StringBuffer工具方法 //数组方式 拼接字符串 .高效... 使用前先实例化. function StringBuffer(){ this._aStr = []; } StringBuffer.prototype.add = function(str){ this._aStr.push(str); return this; } StringBuffer.prototype.toString = function(){ return this._aStr.join(''); } var tempStr = new StringBuffer(); tempStr.add("test+++") .add("test1 append()+++++") .add("test+++") .add("test1 append()+++++") .add("test+++") .add("test1 append()+++++") .add("test+++") .add("test1 append()+++++") .add("test+++") .add("test1 append()+++++") .add("test+++") .add("test1 append()+++++") .add("test+++") .add("test1 append()+++++") .add("test+++") .add("test1 append()+++++") .add("test+++") .add("test1 append()+++++"); </script> </head> <body> </body> </html>
Tags: lt (RSS), utf 8 (RSS), java class (RSS), doctype (RSS), script type (RSS), text javascript (RSS), strict dtd (RSS), prototype (RSS), content type (RSS), text html (RSS), meta (RSS), w3c (RSS), efficiency (RSS), charset (RSS), stringbuffer (RSS), development tools collection (RSS), method description (RSS), astr (RSS)
Permalink: http://www.codeweblog.com/javascript-development-tools-collection-b/





















