this page states:
Note: isPrototypeOf differs from
instanceof operator. In the expression
object instanceof AFunction, the
object prototype chain is checked
against AFunction.prototype, not
against AFunction itself
Ok I don’t really get what they are trying to tell us. Isn’t object instanceof AFunction exactly the same as `AFunction.prototype.isPrototypeOf(object)? or am I wrong?
Why do we need the isPrototypeOf at all?
If i ever need to do p.isPrototypeOf(o) couldn’t I just do o instanceof p.constructor ?
Addtionally, is p.isPrototypeOf(o) functionally equivalent to p===Object.getPrototypeOf(o)?
Object constructors are funky things. From this answer:
An object’s constructor is not read-only, which is why this is possible to do at all. I could assign any value to
p.constructorafterpis created, and this would completely break usinginstead of
Further reading
constructor@ MDCEdit re: OP edit
Those are more similar than your original question, aside from the fact that
Object.getPrototypeOfwasn’t introduced until JavaScript 1.8.1? See John Resig –Object.getPrototypeOf. Perhaps more relevant, the two functions are different in the spec! (warning, PDF link)