inherit js 简单继承模块
继承js简单继承模块用法
function Parent() {}
Parent.prototype.parentMethod = function () { console.log('parent method!'); };
function Child() { Parent.prototype.constructor.call(this); }
设置继承关系在添加子类原型方法前:
inherit(Parent, Child);
Child.prototype.childMethod = function () { console.log('child method!'); };
创建子类实例:
var child = new Child();
child.childMethod();
下载地址
用户评论