Note that __proto__ is not recommended for implicit archetypes and getPrototypeOf() is better.

code

 function myInstanceof(left, right) {
            let proto = Object.getPrototypeOf(left);
            let prototype = right.prototype
            while (proto) {
                if (proto === prototype) return true;
                proto = Object.getPrototypeOf(proto)
            }
            return false
        }
Copy the code

test

let A = function () {}let a = new A()

        console.log(myInstanceof(a, A));
Copy the code

Record the record!