实现 instanceof 运算
by Alex Liu
JavaScript
function isInstanceof(ins, cons){
let insPro
do{
insPro = ins.__proto__
if(insPro == null){
return false
}
if(insPro === cons.prototype){
return true
}
} while (insPro)
return false
}
function Person(name){
this.name = name
}
const p = new Person("xiaoming")
console.log(isInstanceof(p, Person))