<script type="text/javascript">
function SuperType(){
this.spuerName = 'SuperType';
this.arr = ['aa','bbb','ccc'];
SuperType.prototype.getSuperName = function(){
return this.spuerName;
};
}
function SubType(){
this.subName = 'subName';
}
SubType.prototype = new SuperType(); // 继承的一种实现
var sub = new SubType(); // 这里的 new 是对subtype继承的属性(supertype) 进行添加
sub.superName = 'name';
sub.arr.push('ddd');
console.log(sub.superName);
console.log(sub.getSuperName());
var sub2 = new SubType(); // 这里的 new 是对subtype继承的属性 进行添加
console.log(sub2.getSuperName());
console.log(sub2.arr);
</script>
// 运行结果
name
SuperType
SuperType
Array[4]
0: "aa"
1: "bbb"
2: "ccc"
3: "ddd"