We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function myInstanceof(left, right){ //如果是基础数据类型,直接返回false if(typeof left !== 'object' || left === null) return false; //获取实例的原型对象,这里采用Object.getPrototypeOf let proto = Object.getPrototypeOf(left); while(true){ //查找到原型链的顶端还没找到,返回false if(proto === null) return false; //在原型链中找到构造函数的prototype,返回true if(proto === right.prototype) return true; //当前步骤未找到,将proto重新赋值为proto的原型,重新执行循环 proto = Object.getPrototypeOf(proto); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: