<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 新舊對比 在準備課程的這個時間 https://github.com/madrobby/zepto/blob/master/src/zepto.js#files 其中的代碼中,`zepto.Z`是這樣實現的: ```js function Z(dom, selector) { var i, len = dom ? dom.length : 0 for (i = 0; i < len; i++) this[i] = dom[i] this.length = len this.selector = selector || '' } // `$.zepto.Z` swaps out the prototype of the given `dom` array // of nodes with `$.fn` and thus supplying all the Zepto functions // to the array. This method can be overridden in plugins. zepto.Z = function(dom, selector) { return new Z(dom, selector) } $.fn = { // ...很多屬性... } zepto.Z.prototype = Z.prototype = $.fn ``` 再把之前的拿出來對比一下 ```js // `$.zepto.Z` swaps out the prototype of the given `dom` array // of nodes with `$.fn` and thus supplying all the Zepto functions // to the array. Note that `__proto__` is not supported on Internet // Explorer. This method can be overriden in plugins. zepto.Z = function(dom, selector) { dom = dom || [] dom.__proto__ = $.fn dom.selector = selector || '' return dom } $.fn = { // ...很多屬性... } ``` <br> ## 兩者的異同 第二種實現方式我們已經講完了,最終它返回的一個數組,并且強制將`__proto__`修改為`$.fn`這個對象。這個修改發生在對象上,修改的隱式原型。 ![](https://box.kancloud.cn/2016-07-04_577a764d9fab9.png) 而第一種實現方式,是直接將構造函數的原型修改了,即 `Z.prototype = $.fn`,經過這樣一改,構造函數再`new`出來的對象的隱式原型`__proto__`自然就指向了`$.fn`。 ![](https://box.kancloud.cn/2016-07-04_577a764dc04f6.png) 另外,第一種方式返回的是一個`對象數組`,而第二種返回的是一個數組。何謂對象數組?——即可以模擬進行數組操作的對象。 ```js var objArray = { 0: 'abc', 1: 'bcd', 2: 'cde', length: 3 }; console.log( objArray[1] ) console.log( objArray.length ) ``` 那為何不用數組,而用對象數組?——對象本質上更加靈活、直觀,例如 ```js objArray.selector = ''; ```
                  <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>

                              哎呀哎呀视频在线观看