What's the difference between isPrototypeOf and intanceof in Javascript?
Posted
by Steffen Heil
on Stack Overflow
See other posts from Stack Overflow
or by Steffen Heil
Published on 2010-03-17T17:28:45Z
Indexed on
2010/03/17
17:31 UTC
Read the original article
Hit count: 363
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
© Stack Overflow or respective owner