For value types, you can use TypeOf to judge, but typeof the reference type when the return value is only object/function, do not know exactly which one. The instance will be used at this time. For example
, F1 is created by the Foo function, but why is "F1 instanceof Object" true?
As for why later, say the rule of instanceof judgment. According to the above code see:
The first variable of the instance operator is an object, temporarily called A; the second variable is generally a function, temporarily called B.
The rule of instance is to find the line along the _proto_ of a, and to find it along the line of the prototype of B, if both lines can find the same reference, that is, the same object, so long returns True, and returns False if no coincident is found.
According to the above rules, you can see that "F1 instanceof Object" All points to object.prototype, so it returns true.
By the above rules, more bizarre phenomena can be explained, such as:
As can be seen from the above picture, the end is pointing to a place.
Instance represents an inheritance relationship, or the structure of a prototype chain.
Deep understanding of JavaScript prototypes and Closures (5)--instanceof