标签:
function SuperType(name){ this.name=name; this.colors=[‘black‘, ‘white‘] } SuperType.prototype.sayName=function(){ console.log(this.name); } function SubType(name, age){ SuperType.call(this, name); this.age=age; } SubType.prototype=Object.create(SuperType.prototype,{ constructor:{value: SubType} });
console.log(new SuperType(‘derek‘))
console.log(new SubType(‘ben‘, 25))
标签:
原文地址:http://www.cnblogs.com/derek-hu/p/4455926.html