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
No description provided.
The text was updated successfully, but these errors were encountered:
Object.prototype.fakeInstanceOf = function(constructor) { let obj = this; while (true) { if (obj.__proto__ === null) { return false; } if (obj.__proto__ === constructor.prototype) { return true; } obj = obj.__proto__; } }
考察的是原型链的使用,判断一个对象是否是某个构造函数的实例,即看构造函数的原型是否在该对象的原型链上。
Sorry, something went wrong.
function myInstanceof(instance, target) { const targetProto = target.prototype, instanceProto = instance.__proto__; while(instanceProto) { if (instanceProto === targetProto) return true; instanceProto = instanceProto.__proto__; } return false; }
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: