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

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


          網站導航:
           
          主站蜘蛛池模板: 黑河市| 河北区| 同江市| 微博| 长寿区| 贺兰县| 芦溪县| 游戏| 民乐县| 安义县| 隆林| 敦化市| 海伦市| 汉源县| 彰化县| 铜陵市| 济源市| 桃园县| 玉屏| 金山区| 邹城市| 江北区| 建始县| 南城县| 黑水县| 丹江口市| 镇雄县| 玉林市| 拉萨市| 新化县| 平舆县| 锡林郭勒盟| 全南县| 安义县| 读书| 如皋市| 沿河| 泌阳县| 格尔木市| 茂名市| 安康市|