<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 單例模式 在javascript中的單例模式,每個實例化的對象都是相同的,即單個實例 ***** <br> ```javascript /* function Person(){ // new 做了三步 // 第一:在內部創建了一個對象 var obj= new Object(); //第二 修改this this = obj //返回值是這個對象 return this } // s實例化對象 var p1 = new Person(); var p2 = new Person(); console.log(p1 == p2);//false */ /* var _instance; function Person(){ if(_instance){ console.log("這個對象已經存在"); return _instance; } _instance = this; console.log("第一次創建"); } var p1 = new Person(); var p2 = new Person(); console.log(p1 == p2); */ // 有全局變量不安全 // 優化 function Person(){ if(Person._instance){//判斷這個對象是不是已經 存在 console.log("這個對象已經存在了"); return Person._instance;//存在直接返回對象 } //若沒有存在則使它等于this Person._instance = this; console.log("第一次創建對象"); } // 實例化對象 var p1 = new Person(); var p2 = new Person(); console.log(p1 === p2);//true ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看