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

语法:父对象.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

 

posted @ 2017-12-19 17:22  狂奔的小马扎  阅读(904)  评论(0编辑  收藏  举报