题解 | #instanceof#
instanceof
https://www.nowcoder.com/practice/a1169935fd6145899f953ba8fbccb585
// Fn写成小写了 调试了半天
const _instanceof = (target, Fn) => {
let obj = {
number: true,
string: true,
null: true
}
let result = typeof target
if (obj[result]) return false
let proto = target.__proto__
let prototype = Fn.prototype
while (proto) {
if (proto === prototype) return true
if (proto === null) return false
proto = proto.__proto__
}
}