35.instanceof的实现原理是什么

41 阅读1分钟

是通过原型链判断的

A instanceof B

在A的原型链上层层查找,是否有原型等于B的prototype,如果一直找到原型链顶端,都没有找到,就放回false