<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 認識面向對象   1. 一切事物皆對象   2. 對象具有封裝和繼承性   3. 信息隱藏 ## 基本面向對象 ~~~ <script> // 定義一個基本的對象 var parson = { name:"rose", age:25, eat:function(){ // 對象eat方法 alert('eat'); } }; console.log(parson); </script> ~~~ ## 函數構造器構造對象 ~~~ <script> function person(){ } person.prototype = { name : "rose", age : 25, eat : function (){ console.log("from function obj"); return true; } }; var oPerson = new person(); // 創建對象 console.log(oPerson.age); // 調用對象屬性 console.log(oPerson.name); console.log(oPerson.eat()); // 調用對象方法 </script> ~~~ ## 深入JavaScript面向對象 ~~~ <script type="text/javascript"> function people(){ } people.prototype.say = function (){ console.log("hello!"); } function student(){ } student.prototype = new people(); // 通過new對象的方式 使得student類繼承自people var s = new student(); s.say(); // hello! 繼承自父類方法成功 student.prototype.say = function (){ console.log('stu say hello!'); } var s = new student(); s.say(); // stu say hello! 父類方法被復寫了 </script> ~~~ 那如何在子類中調用父類呢? ~~~ <script type="text/javascript"> function people(){ } people.prototype.say = function (){ console.log("hello!"); } function student(){ } student.prototype = new people(); // 通過new對象的方式 使得student類繼承自people var s = new student(); s.say(); // hello! 繼承自父類方法成功 var superSay = student.prototype.say; // 將父類的方法賦值給變量 student.prototype.say = function (){ superSay.call(this); // 調用call方法 console.log('stu say hello!'); } var s = new student(); s.say(); // stu say hello! 父類方法被復寫了 </script> ~~~ ## 另外 閉包 ~~~ <script type="text/javascript"> (function(){ function people(name){ // 傳遞參數 this.name = name; } people.prototype.say = function (){ console.log("hello!"+ this.name); } window.people = people; }()); (function(){ function student(name){ // 傳遞參數 this.name = name; } student.prototype = new people(); // 通過new對象的方式 使得student類繼承自people var superSay = student.prototype.say; // 將父類的方法賦值給變量 student.prototype.say = function (){ superSay.call(this); // 調用方法 console.log('stu say hello!'+this.name); } window.student = student; }()); var s = new student('rose'); s.say(); // stu say hello! 父類方法被復寫了 // 最后結果打印了 hello!rose | stu say hello!rose </script> ~~~
                  <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>

                              哎呀哎呀视频在线观看