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(instance, constructer) { if (typeof instance !== 'object') { return false } while(true) { if (instance === null) { return false } if (instance.__proto__ === constructer.prototype) { return true } instance = instance.__proto__ } } function Person (name) { this.name = name } const p1 = new Person('luo') console.log(myInstanceof(p1, Person)) // true console.log(myInstanceof(p1, Object)) // true
The text was updated successfully, but these errors were encountered:
No branches or pull requests
instanceof 就是在实例的原型链中寻找构造函数的 Prototype
The text was updated successfully, but these errors were encountered: