<script type="text/javascript"> function inheritPrototype(subType,superType){ var prototype = Object(superType.prototype);//创建对象 prototype.constructor = subType;//增强对象 subType.prototype = prototype;//指定对象 } function SuperType(name){ this.name = name; this.color = ["red","blue","greed"]; } SuperType.prototype.sayName=function(){ alert(this.name); } function SubType(name,age){ SuperType.call(this,name); this.age=age; } inheritPrototype(SubType,SuperType); SubType.prototype.sayAge=function(){ alert(this.age); }; //var parent = new SuperType("Hello"); var sub = new SubType('Hello', 18); alert(sub.name); alert(sub.age); alert(sub.color); sub.sayName(); sub.sayAge(); </script>