function myInstanceof(x, fn) {
if (typeof x !== 'object') return false
let p = x.__proto__
if (p === null) return false
if (p !== fn.prototype) {
return myInstanceof(p, fn)
} else {
return true
}
}
手写instanceof
最新推荐文章于 2024-07-24 16:20:17 发布