SOURCE

function myInstanceof(left,right){
    let rightPrototype = right.prototype
    let leftProto = left.__proto__
    while(true){
        if(leftProto === null){
            return false
        }
        if(leftProto === rightPrototype){
            return true
        }
        leftProto = leftProto.__proto__
        
    }
}

function Foo() {
}
console.log(myInstanceof(Object,Object))
console.log(myInstanceof(Foo,Foo))
// Object instanceof Object // true
// Function instanceof Function // true
// Function instanceof Object // true
// Foo instanceof Foo // false
// Foo instanceof Object // true
// Foo instanceof Function // true

console 命令行工具 X clear

                    
>
console