1functionSuperType(){
2this.property=
true;
3}
45SuperType.prototype.getSuperValue=
function(){
6returnthis.property;
7};
89functionSubType(){
10this.subproperty=
false;
11}
1213//继承了SuperType
14SubType.prototype=
newSuperType();
1516SubType.prototype.getSuperValue=
function(){
17returnthis.subproperty;
18};
1920varinstance=
newSubType();
21console.log(instance.getSuperValue());
2223console.log(instance
instanceofObject);
24console.log(instance
instanceofSuperType);
25console.log(instance
instanceofSubType);
2627console.log(Object.prototype.isPrototypeOf(instance));
28console.log(SuperType.prototype.isPrototypeOf(instance));
29console.log(SubType.prototype.isPrototypeOf(instance));
优质内容筛选与推荐>>
1、OCR大突破:Facebook推出大规模图像文字检测识别系统——Rosetta2、WordPress前端html代码压缩优化,附对应知更鸟主题压缩报错的解决方案3、Mysql命令行操作教程【一】4、ASP.NET安全隐患的临时解决方法5、Redis集群方案怎么做?大牛给你介绍五种方案!