码迷,mamicode.com
首页 > Web开发 > 详细

js之类式继承,原型继承

时间:2015-05-19 18:55:58      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:

类式继承

//extend function
function extend(subClass,superClass){
  var F=function(){};
  F.prototype=superClass.prototype;
  subClass.prototype=new F();
  subClass.prototype.constructor=subClass;

  subClass.superclass=superClass.prototype;
  if(superClass.prototype.constructor == Object.prototype.constructor){
    superclass.prototype.constructor = superClass;
  }
}
//class Person
function Person(){

}

//class Author
function Author(){
  Author.superclass.constructor.call();
}
extend(Author,Person)
Author.prototype.sayName=function(){
  
};

 

 

js之类式继承,原型继承

标签:

原文地址:http://www.cnblogs.com/byronvis/p/4515145.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!