What's the difference between isPrototypeOf and intanceof in Javascript?
- by Steffen Heil
Hi
In some of my own older code, I use the following:
Object.prototype.instanceOf = function( iface )
{
return iface.prototype.isPrototypeOf( this );
};
Then I do (for example)
[].instanceOf( Array )
This works, but it seems the following would do the same:
[] instanceof Array
Now, surly this is only a very simple example. My question therefor is:
Is a instanceof b ALWAYS the same as b.prototype.isPrototypeOf(a) ?
Regards,
Steffen