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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] # Object.getPrototypeOf(obj) 返回指定對象的原型(內部[[Prototype]]屬性的值) ``` var proto = {}; var obj = Object.create(proto); Object.getPrototypeOf(obj) === proto; // true var reg = /a/; Object.getPrototypeOf(reg) === RegExp.prototype; // true ``` <br> # Object.getOwnPropertyDescriptor(obj, prop) 返回指定對象上一個自有屬性對應的屬性描述符。(自有屬性指的是直接賦予該對象的屬性,不需要從原型鏈上進行查找的屬性) <br> 參數 * obj:需要查找的目標對象 * prop:目標對象內屬性名稱 返回值 * 如果指定的屬性存在于對象上,則返回其屬性描述符對象(property descriptor),否則返回 undefined ``` var o, d; o = { get foo() { return 17; } }; d = Object.getOwnPropertyDescriptor(o, "foo"); // d { // configurable: true, // enumerable: true, // get: /*the getter function*/, // set: undefined // } ``` <br> <br> # Object.getOwnPropertyNames(obj) 返回一個由指定對象的所有自身屬性的屬性名(包括不可枚舉屬性但不包括Symbol值作為名稱的屬性)組成的數組。 <br> 參數 * obj一個對象,其自身的可枚舉和不可枚舉屬性的名稱被返回。 返回值 * 在給定對象上找到的自身屬性對應的字符串數組。 <br> ``` var arr = ["a", "b", "c"]; console.log(Object.getOwnPropertyNames(arr).sort()); // ["0", "1", "2", "length"] // 類數組對象 var obj = { 0: "a", 1: "b", 2: "c"}; console.log(Object.getOwnPropertyNames(obj).sort()); // ["0", "1", "2"] ``` <br> <br> # Object.create(proto, [propertiesObject]) 創建一個新對象,使用現有的對象來提供新創建的對象的__proto__。 <br> 參數 * proto:新創建對象的原型對象。 * propertiesObject:可選。如果沒有指定為 undefined,則是要添加到新創建對象的可枚舉屬性(即其自身定義的屬性,而不是其原型鏈上的枚舉屬性)對象的屬性描述符以及相應的屬性名稱。這些屬性對應Object.defineProperties()的第二個參數。 ``` const person = { isHuman: false, printIntroduction: function () { console.log(`My name is ${this.name}. Am I human? ${this.isHuman}`); } }; const me = Object.create(person); me.name = "Matthew"; // "name" is a property set on "me", but not on "person" me.isHuman = true; // inherited properties can be overwritten me.printIntroduction(); // expected output: "My name is Matthew. Am I human? true" ``` <br> <br> # Object.defineProperty(obj, prop, descriptor) 直接在一個對象上定義一個新屬性,或者修改一個對象的現有屬性, 并返回這個對象。 <br> 參數 * obj:要在其上定義屬性的對象。 * prop:要定義或修改的屬性的名稱。 * descriptor:將被定義或修改的屬性描述符。 <br> <br> # Object.defineProperties(obj, props) 直接在一個對象上定義新的屬性或修改現有屬性,并返回該對象。 <br> 參數 * obj:在其上定義或修改屬性的對象。 * props:要定義其可枚舉屬性或修改的屬性描述符的對象。對象中存在的屬性描述符主要有兩種:數據描述符和訪問器描述符(更多詳情,請參閱Object.defineProperty())。描述符具有以下鍵: * configurable:當且僅當該屬性描述符的類型可以被改變并且該屬性可以從對應對象中刪除。默認為 false * enumerable:當且僅當在枚舉相應對象上的屬性時該屬性顯現。默認為 false * value:與屬性關聯的值。可以是任何有效的JavaScript值(數字,對象,函數等)。默認為 undefined. * writable:當且僅當與該屬性相關聯的值可以用assignment operator改變時。默認為 false * get:作為該屬性的 getter 函數,如果沒有 getter 則為undefined。函數返回值將被用作屬性的值。默認為 undefined * set:作為屬性的 setter 函數,如果沒有 setter 則為undefined。函數將僅接受參數賦值給該屬性的新值。默認為 undefined <br> ``` var obj = {}; Object.defineProperties(obj, { 'property1': { value: true, writable: true }, 'property2': { value: 'Hello', writable: false } // etc. etc. }); ``` <br> <br> # Object.seal(obj) 封閉一個對象,阻止添加新屬性并將所有現有屬性標記為不可配置。當前屬性的值只要可寫就可以改變。 ``` const object1 = { property1: 42 }; Object.seal(object1); object1.property1 = 33; console.log(object1.property1); // expected output: 33 delete object1.property1; // cannot delete when sealed console.log(object1.property1); // expected output: 33 ``` <br> <br> # Object.freeze(obj) 可以凍結一個對象。一個被凍結的對象再也不能被修改;凍結了一個對象則不能向這個對象添加新的屬性,不能刪除已有屬性,不能修改該對象已有屬性的可枚舉性、可配置性、可寫性,以及不能修改已有屬性的值。此外,凍結一個對象后該對象的原型也不能被修改。freeze() 返回和傳入的參數相同的對象。 ``` const object1 = { property1: 42 }; const object2 = Object.freeze(object1); object2.property1 = 33; // Throws an error in strict mode console.log(object2.property1); // expected output: 42 ``` # Object.preventExtensions(obj) 讓一個對象變的不可擴展,也就是永遠不能再添加新的屬性。 <br> <br> # Object.isSealed(obj) 判斷一個對象是否被密封 <br> <br> # Object.isFrozen(obj) 判斷一個對象是否被凍結 <br> <br> # Object.isExtensible(obj) 判斷一個對象是否是可擴展的(是否可以在它上面添加新的屬性)。 <br> <br> # Object.keys(obj) 返回一個由一個給定對象的自身可枚舉屬性組成的數組,數組中屬性名的排列順序和使用 for...in 循環遍歷該對象時返回的順序一致 。 ``` // simple array var arr = ['a', 'b', 'c']; console.log(Object.keys(arr)); // console: ['0', '1', '2'] // array like object var obj = { 0: 'a', 1: 'b', 2: 'c' }; console.log(Object.keys(obj)); // console: ['0', '1', '2'] var anObj = { 100: 'a', 2: 'b', 7: 'c' }; console.log(Object.keys(anObj)); // console: ['2', '7', '100'] ```
                  <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>

                              哎呀哎呀视频在线观看