Alex刺客

          Dancing fingers, damage world. -- 舞動手指,破壞世界.

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            57 隨筆 :: 0 文章 :: 76 評論 :: 0 Trackbacks
           1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           2<html xmlns="http://www.w3.org/1999/xhtml">
           3    <head>
           4        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
           5        <title>實(shí)例</title>
           6        <script type="text/javascript">
           7            /*
           8            *    項(xiàng)目: book -> Javascript高級程序設(shè)計(jì).pdf -> 第3章 -> 3.5.8實(shí)例
           9            *
          10            *    說明:自定義對象的使用
          11            *
          12            *    練習(xí)者: Alex刺客
          13            *
          14            *    日期: 2009-12-13
          15            */

          16
          17            /*
          18                定義一個(gè)一次合并當(dāng)前對象所有字符串的StringBuffer類
          19            */

          20            
          21            function StringBuffer () {
          22                this._strings_ = new Array;
          23                if (typeof StringBuffer._initialized == "undefined"{
          24                    StringBuffer.prototype.append = function (str){
          25                        this._strings_.push(str);
          26                    }

          27                    StringBuffer.prototype.toString = function(){
          28                        return this._strings_.join("");
          29                    }

          30                }

          31            }

          32            
          33            var stringBufferTest = new StringBuffer();
          34            var string2 = new StringBuffer();
          35            stringBufferTest.append("Hello ");
          36            stringBufferTest.append("World! ");
          37            stringBufferTest.append("Welcome");
          38            stringBufferTest.append("to ");
          39            stringBufferTest.append("JavaScript! ");
          40            string2.append("Alex ");
          41            string2.append("刺客!");
          42            var result = stringBufferTest.toString();
          43            var test = string2.toString();
          44            alert(result);
          45            alert(test);
          46        </script>
          47    </head>
          48    <body>
          49    </body>
          50</html>
          posted on 2009-12-13 22:54 Alex刺客 閱讀(199) 評論(0)  編輯  收藏 所屬分類: JavaScript
          主站蜘蛛池模板: 宝兴县| 龙泉市| 门源| 建平县| 盐山县| 启东市| 任丘市| 云阳县| 柏乡县| 措美县| 张掖市| 手游| 专栏| 衡东县| 邮箱| 长沙县| 兴化市| 隆尧县| 白玉县| 肃北| 东台市| 本溪市| 锡林浩特市| 巴青县| 宜春市| 宿州市| 阿尔山市| 定结县| 南昌县| 龙胜| 临邑县| 高碑店市| 汶川县| 阿荣旗| 星子县| 仁化县| 宁陕县| 景谷| 朝阳县| 泗阳县| 明溪县|