<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 功能強大 支持多語言、二開方便! 廣告
                [TOC] # Object 靜態成員對象 <br> ```javascript var?obj?={ name?:"wc", age?:3, say:function(){ console.log("世界,你好"); } } ``` ***** ## 1.length 形參個數 <br> ## 2.name 方法名稱 <br> ## 3.assign 將多個對象合并到一個對象中并返回 ```javascript var obj = {name:"Neld", age:10}; console.log(Object.assign(obj, {info: "xxx"}, {name: "zs"})); ``` <br> >[success]返回結果為:{name:"zs", age:10, info:"xxx"}, **如果多個對象想存在相同的屬性,后面會將前面屬性值覆蓋。** <br> ## 4.create 創建對象,并設置原型對象, ``` console.log(Object.create(null)); ``` **創建的對象沒有原型鏈** <br> ## 5.is 判斷兩個參數是否相等,等同于=== >[danger]**注意兩個特殊的例子** ```javascript console.log(0 === -0);//true console.log(Object.is(-0, 0));//false console.log(NaN === NaN);//false console.log(Object.is(NaN, NaN));//true ``` <br> ## 6.getOwnPropertyDescriptor 獲取當前對象中的指定的屬性描述對象 ``` console.log(Object.getOwnPropertyDescriptor(obj,"name")); ``` >[danger]每個屬性描述對象都存在下面四個屬性: >[info]configurable:屬性可配置型,false,當前屬性不能被刪除,并且后面不能再改變該描述對象 默認值是true enumerable:可枚舉性,false,當前屬性不是被循環遍歷到 默認值是true value:當前屬性的值 writable:可寫性,false,當前屬性的值不能被修改 默認值是true <br> ## 7.getOwnPropertyDescriptors 獲取所有屬性的描述對象 ``` console.log(Object.getOwnPropertyDescriptors(obj)); ``` <br> ## 8.defineProperties 一次定義多個屬性的可操作性 (configurable enumerable value writable) ***** ```javascript Object.defineProperties(obj,{ ????name:{ ????????configurable:true,//當前屬性可以被刪除 ????}, ????age:{ ????????configurable:false,//當前屬性不可刪除 ????}, }); console.log(delete?obj.name);?//刪除成功返回值是true? console.log(obj.name);//undefined console.log(delete?obj.age);//false console.log(obj.age);//3 ``` ## 9.defineProperty 定義當前指定屬性的可操作性 (configurable enumerable value writable) ```javascript Object.defineProperty(obj,"name",{ configurable:true, }); console.log(delete?obj.name);//刪除成功返回值是true? console.log(obj.name);//undefined ``` **注意** 當為一個存在的屬性設置可操作性時,如果只是修改屬性描述對象的部分屬性,其他的為默認值。 當為一個不存在的屬性設置可操作性時,如果只是修改屬性描述對象的部分屬性,其他的為false。 <br> ## 10.keys 獲取當前對象所有屬性的名稱,不可枚舉的屬性除外 ```javascript Object.defineProperty(obj,"name",{ ????enumerable:false,//可枚舉性,false不可枚舉 }) console.log(Object.keys(obj));??//拿到age,name被設置了不可枚舉性,拿不到; ``` <br> ## 11.getOwnPropertyNames 獲取當前對象所有屬性的名稱,包括不可枚舉的屬性 ``` console.log(Object.getOwnPropertyNames(obj));//name,age ``` <br> ## 12.isExtensible 檢查當前對象是否可擴展,false,不能添加屬性,默認值是true ``` console.log(Object.isExtensible(obj));//true ``` <br> ## 13.isSealed 檢查當前對象是否是被密封的,true,不能添加和刪除屬性 ``` console.log(Object.isSealed(obj));//false ``` <br> ## 14.isFrozen 檢查當前對象是否是被凍結的,true,不能添加,刪除和修改屬性 ``` console.log(Object.isFrozen(obj));//false ``` <br> ## 15.preventExtensions 阻止當前對象的可擴展性,就是添加不了屬性了 ```javascript Object.preventExtensions(obj);//不能添加屬性,可以刪除和修改 obj.corlor?=?"red"; obj.age?=?18; console.log(delete?obj.name) console.log(obj); ``` <br> ## 16.seal 密封當前對象、添加刪除不了,可以修改 ```javascript Object.seal(obj);//不能刪除,不能添加,可以修改 obj.corlor?=?"red"; obj.age?=?18; console.log(delete?obj.name) console.log(obj); ``` <br> ## 17.freeze 凍結當前對象、不能添加、不能修改、不能刪除 ```javascript Object.freeze(obj); obj.corlor?="red"; obj.age?\=18; console.log(delete?obj.name) console.log(obj); ``` <br> ## 18.entries 獲取到所有成員,以數組形式返回 ```javascript var?obj2?\={ name:"lw", age:33, sex?:0, say:function(){ console.log("世界,你好"); }, } console.log(obj2); console.log(Object.entries(obj2)); ```
                  <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>

                              哎呀哎呀视频在线观看