unliar / unliar.github.io

一个已经不再使用的静态博客,新的博客在后边。
https://happysooner.com
0 stars 0 forks source link

实现一个 instanceOf #48

Open unliar opened 3 years ago

unliar commented 3 years ago
const InstanceOff = (L, R) => {
    var O = R.prototype;
    L = L.__proto__;
    while (true) {
        if (L === null) return false;
        if (O === L) return true;
        L = L.__proto__; // 不断的查找实例的__proto__
    }
};