function myInstanceOf(left, right) {
if (!['function', 'object'].includes(typeof left) || left === null) return false
let leftProto = left.__proto__
let rightPrototype = right.prototype
while (true) {
if (leftProto === null) return false
if (leftProto === rightPrototype) return true
leftProto = leftProto.__proto__
}
}
自定义实现instanceof
最新推荐文章于 2024-11-12 11:19:19 发布