<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國際加速解決方案。 廣告
                >[success] # 數組類型判斷 ~~~ var a = []; // 1.基于instanceof a instanceof Array; // 2.基于constructor a.constructor === Array; // 3.isPrototypeOf() 方法允許你檢查一個對象是否存在于另一個對象的原型鏈上。 Array.prototype.isPrototypeOf(a); // 4.基于getPrototypeOf Object.getPrototypeOf(a) === Array.prototype; // 5.基于Object.prototype.toString 這是最推薦的形式 Object.prototype.toString.apply(a) === '[object Array]'; ~~~ >[danger] ##### 關于isPrototypeOf 和 instance of ~~~ 1.通過下面例子可以看出,'instance of' 和 'isPrototype' 都可以對深層次檢測,即在原型鏈上不停找是否有 相同的 2.從'Mdn' 定義來看`isPrototypeOf()`與`instanceof`運算符不同。在表達式 "`object instanceof AFunction`"中, `object`的原型鏈是針對`AFunction.prototype`進行檢查的,而不是針對`AFunction`本身。 3.通過上面定義和下面案例可以看出 當想通過查找關系從屬的時候。'instanceof' 默認幫助我們從'prototype' 去對比關系,但是'isPrototypeOf' 如果你沒有指定'prototype'話查出結果 是針對當前對象本身導致結果為false ~~~ ~~~ class B {} class A extends B {} const a = new A() console.log(a instanceof A) // true console.log(A.prototype.isPrototypeOf(a)) // true console.log(A.isPrototypeOf(a)) // false ~~~ >[danger] ##### es6 isArray ~~~ 1. Array.isArray 判斷是不是數組 其實他polyfill if (!Array.isArray){ Array.isArray = function(arg){ return Object.prototype.toString.call(arg) === '[object Array]'; }; } ~~~
                  <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>

                              哎呀哎呀视频在线观看