您的位置:首页 > Web前端 > JavaScript

JS 对象API之判断父对象是否在子对象的原型链上

2017-12-19 17:22 190 查看

语法:父对象.prototype.isPrototypeOf(子对象)

 

代码栗子:

function Student(){
this.name = "小马扎";
this.age = 18;
}
var sky = new Student();
var img = new Image();
console.log(Student.prototype.isPrototypeOf(sky));    // true
console.log(Student.prototype.isPrototypeOf(img));    // false

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: