<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國際加速解決方案。 廣告
                [TOC] ## Object類型 ### Object 實例化 到目前為止,我們看到的大多數引用類型值都是 `Object` 類型的實例;而且,`Object` 也是 ECMAScript 中使用最多的一個類型。雖然 `Object` 的實例不具備多少功能,但對于在應用程序中存儲和傳輸數據而言,它們卻是是非常理想的選擇。 > JavaScript 中有句話說,[萬物皆對象](https://segmentfault.com/a/1190000012037062),當然 JavaScript 中不僅僅是對象,還有其他的,但是在JavaScript對象的存在是多方面的,應用也是最多的。 創建 `Object` 實例的方式: - 使用 `new` 操作符進行實例化 ```js var person = new Object(); person.name = "SpiritLing"; person.age = 29; ``` - 使用對象字面量的表達式 ```js var person = { "name" : "SpiritLing", "age" : 22 }; ``` 在使用對象字面量的表達式時,如果花括號中為空,則和 `new` 操作符實例化一樣。在函數傳入數據時,使用字面量表達式,可以更清楚展示,能夠給人一種封裝數據的感覺。 ### 對象屬性訪問 - 點表示法 ```js var person = { "name" : "SpiritLing", "1" : 22 }; console.log(person.name); //"SpiritLing" console.log(person.1); //Error:Uncaught SyntaxError: Unexpected number ``` 如上所示,使用點表示法可以獲取屬性,但是當鍵名(或者說屬性名)是數字或者其他特殊字符時,會出現報錯問題。所以我們需要使用另外一種方式。 - 方括號表示法 ```js var person = { "name" : "SpiritLing", "1" : 22 }; console.log(person["name"]); //"SpiritLing" console.log(person["1"]); //22 ``` 當使用方括號表示法時,可以準確的獲取到屬性,這也是JavaScript中的推薦用法。
                  <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>

                              哎呀哎呀视频在线观看