Why does the following return false?
Object.prototype instanceof Object
Because it basically asks whether Object.prototype does inherit from Object's .prototype object: It does not.
a instanceof b is equivalent to b.prototype.isPrototypeOf(a) - it tests whether b.prototype is in the prototype chain of a. In your case, it is not in the chain, because it is the start of the chain itself. isPrototypeOf is not reflexive.
new is just syntactic sugar (like ES6 classes are, but with more "common" syntax)b instanceof a instead of a instanceof b in your particular example.a is the instance, b is the constructor.Referencing MDN:
The
instanceofoperator tests whether an object has in its prototype chain theprototypeproperty of a constructor.
Object.prototype.toString() === "[object Object]".Functionwas not either, but isinstanceof Objecttypeof Object.prototypeis"object".type(in terms of the language) of the object, not its ancestor name.