You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The instanceof operator compares the constructors of its two operands
This is a bit misformulated and can be wrong understood: according to MDN, instanceof compares not constructor (property of prototype object, but the exact link to prototype objects.
If you set only constructor property, the instanceof will return false, because despite prototype objects looks equal, they are actually different objects:
function A(){}
function B(){}
B.prototype.constructor = A; // *
// has the same constructor
B.prototype.constructor === A; // true
// but this does not mean its an instance of
new B() instanceof A; // false
The text was updated successfully, but these errors were encountered:
This is a bit misformulated and can be wrong understood: according to MDN,
instanceof
compares notconstructor
(property ofprototype
object, but the exact link to prototype objects.If you set only
constructor
property, theinstanceof
will returnfalse
, because despiteprototype
objects looks equal, they are actually different objects:The text was updated successfully, but these errors were encountered: