I found this example at javascript.info:
function Rabbit() { };
var rabbit = new Rabbit;
alert(rabbit instanceof Rabbit);
Alright, rabbit instanceof Rabbit is going to give us true if rabbit is a Rabbit and false if rabbit is a Walrus (i.e. not a Rabbit). It turns out that, in this example, rabbit is a Rabbit and hence we will be given true.
No comments:
Post a Comment