原型链
![](https://i-blog.csdnimg.cn/blog_migrate/89a54db23badd893e5dce533a3e77cf5.png)
instanceOf手写实现
思路:沿着原型链查找
function instanceOfs(target, type) {
if(typeof target !== 'object' || target == null) {
return false
}
let p = target.__proto__
while(p) {
if(p == type.prototype) {
return true
}
p = p.__proto__
}
return false
}