Using instanceof operator to check the subclass created by Prototype Chaining : instanceof : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » instanceof »

 

Using instanceof operator to check the subclass created by Prototype Chaining













function SubClass() {
}

SubClass.prototype = new BaseClass();

SubClass.prototype.name = "";
SubClass.prototype.sayName = function () {
    alert(this.name);
};
var objA = new BaseClass();
var objB = new SubClass();

var objB = new SubClass();
alert(objB instanceof BaseClass);    //outputs "true";
alert(objB instanceof SubClass);    //outputs "true"







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» instanceof