大鳥的學習樂園
          路漫漫其修遠兮,吾將上下而求索
          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 大鳥 閱讀(218) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 洪江市| 边坝县| 贺州市| 阿尔山市| 会同县| 丰顺县| 松潘县| 冷水江市| 安远县| 徐水县| 东阿县| 始兴县| 时尚| 舞阳县| 得荣县| 昌都县| 青龙| 吕梁市| 泉州市| 衡东县| 共和县| 大同县| 铜陵市| 贵溪市| 大石桥市| 衢州市| 阿坝县| 柳河县| 遵义市| 通州市| 安国市| 沿河| 前郭尔| 易门县| 房山区| 开化县| 云浮市| 中宁县| 乌兰浩特市| 辉县市| 维西|