大鳥的學習樂園
          路漫漫其修遠兮,吾將上下而求索
          posts - 26,comments - 27,trackbacks - 0
          function Parent(name){
          this.name = name;
          }
          Parent.prototype.say = function(){
          alert(this.name);
          }
          var parent = new Parent("wwwwww");
          parent.say();
          function Child(name,password){
          Parent.call(this,name);
          this.password = password;
          }
          Child.prototype = new Parent();
          Child.prototype.sayword = function(){
          alert(this.password);
          }
          var child = new Child("111111","222222222");
          child.sayword();

          ////用call實現繼承
          function Parent(name){
          this.name = name;
          this.say = function(){
          alert(this.name );
          }
          }
          function Child(name,password){
          Parent.call(this,name);
          this.password = password;
          }
          var child = new Child("123123","sssss");
          child.say();
          */
          //用APPLY實現繼承
          /*
          function Parent(name){
          this.name= name;
          this.say= function(){
          alert(this.name);
          }
          }
          function Child(name,password){
          Parent.apply(this,new Array(name));
          this.password = password;
          this.sayworld = function(){
          alert(this.password + this.name);
          }
          }
          var parent = new Parent("zhangsan");
          var child = new Child("lisi","123456");
          parent.say();
          child.say();
          child.sayworld();




          posted on 2011-05-28 09:58 大鳥 閱讀(217) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 芜湖市| 衢州市| 海南省| 徐水县| 宽甸| 乡城县| 中宁县| 三江| 博乐市| 北流市| 平南县| 乐陵市| 绥棱县| 西城区| 临江市| 吴旗县| 南丹县| 洪泽县| 洛隆县| 柘城县| 盘锦市| 渭源县| 安义县| 鲜城| 灵宝市| 阿克苏市| 云龙县| 绥化市| 宁南县| 山东| 五常市| 炎陵县| 景宁| 锡林郭勒盟| 平阳县| 铜陵市| 常山县| 仙游县| 榆树市| 南皮县| 丹凤县|