function SuperType(){
this.colors = ["red", "blue", "green"];
}
SuperType.prototype.foo = function() { console.log('foo');};
function SubType(){
//inherit from SuperType
SuperType.call(this);
}
Subtype.prototype = new SuperType();
var instance1 = new SubType();
instance1.colors.push("black");
alert(instance1.colors); //”red,blue,green,black”
var instance2 = new SubType();
alert(instance2.colors); //”red,blue,green”
可不可以直接让Subtype.prototype = SuperType.prototype,两个原型相等。