https://github.com/zjy4fun/notes/tree/main/demos/js-instanceof
原型就是一个对象,instanceof 就是检查构造函数的原型是否在对象的原型链上
function myInstanceOf(obj, constructorFn) {
const prototype = constructorFn.prototype
while(obj !== null) {
if(obj.__proto__ === prototype) {
return true
}
obj = obj.__proto__
}
return false
}
标签:instanceOf,__,obj,实现,JS,原型,prototype From: https://www.cnblogs.com/zjy4fun/p/17691906.html