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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                常用的原生函數: String() Number() Boolean() Array() Object() Function() RegExp() Date() Error() ``` var a = new String("abc"); a; //{0: "a", 1: "b", 2: "c"} (String{"abc"}) typeof a; //object a.toString(); //abc Object.prototype.toString.call(a); //[object String] ``` #### 一、內部屬性[[class]] 所有typeof為object的對象(或數組)都包含這個屬性 ``` var a = [1, 2, 3]; var b = {a: 1, b:2}; var c = null; Object.prototype.toString.call(a); //[object Array] a.toString(); //1, 2, 3 Object.prototype.toString.call(b); //[object Object] b.toString(); //[object Object] Object.prototype.toString.call(c); //[object Null] c.toString(); //TypeError Object.prototype.toString.call(undefined); //[object Undefined] undefined.toString(); //TypeError //基本類型一樣可以使用[[class]],它們被各自的原生函數包裝了 Object.prototype.toString.call("abc"); //[object String] Object.prototype.toString.call(42); //[object Number] Object.prototype.toString.call(true); //[object Boolean] //函數也是如此 var e = function(){} e.toString; //"function(){}" Object.prototype.toString.call(e); //[object Function] ``` #### 二、封裝對象釋疑 使用封裝對象(原生函數)時要注意一些特殊情況,如Boolean所創建的變量永遠是true,及時它接收的參數為false ``` var a = new Boolean(false) if(!a){//永遠不會走到這里} ``` #### 三、獲取封裝對象的值 ``` var a = new String("abc"); var b = new Number(42); var c = new Boolean(true); a; //String{"abc"} b; //Number{42} c; //Boolean{true} a.valueOf(); //"abc" b.valueOf(); //42 c.valueOf(); //true ``` #### 四、原生函數作為構造函數(盡量避免,最好用字面量方式) 當Array只有一個參數時,該參數作為數組的長度而不是數組的內容 ``` var a = new Array(1, 2, 3); //[1, 2, 3] var b = new Array(3); //[empty * 3] //至少有一個空單元的數組就是稀疏數組,比如[1, undefined, 3] var a = new Array(3); var b = [undefined, undefined, undefined]; var c = []; c.length = 3; // a\b\c三者顯示的結果相同 ```
                  <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>

                              哎呀哎呀视频在线观看