Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether one class is inhereted of another class?

I'm using Ext4...

How to check whether one class is inherited of another class?

for example:

Ext.define("A", {});
Ext.define("B", { extend: "A" });
Ext.define("C", { extend: "B" });

var a = Ext.create("A");
var c = Ext.create("C");

I need something like this: c instanceof a

???

Thanks

like image 992
Eugene Petrov Avatar asked Aug 17 '11 07:08

Eugene Petrov


People also ask

Is there a way to check if a class is a subclass of another class?

Python issubclass() is built-in function used to check if a class is a subclass of another class or not. This function returns True if the given class is the subclass of given class else it returns False. Parameters: Object: class to be checked.

How do you check if a class inherits from another class python?

Two built-in functions isinstance() and issubclass() are used to check inheritances. The function isinstance() returns True if the object is an instance of the class or other classes derived from it. Each and every class in Python inherits from the base class object .

Can classes inherit from other classes?

Inheritance enables you to create new classes that reuse, extend, and modify the behavior defined in other classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. A derived class can have only one direct base class.


2 Answers

(Based on @troelskn 's comment)

http://jsfiddle.net/miriam/ugQHB/

c instanceof A

returns true.

like image 81
Miriam Avatar answered Oct 08 '22 12:10

Miriam


You can use isXtype method. See docs here: Ext.AbstractComponent

like image 34
dbrin Avatar answered Oct 08 '22 12:10

dbrin