admin管理员组

文章数量:1415460

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

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

Share Improve this question edited Aug 17, 2011 at 7:32 Reporter 3,9365 gold badges35 silver badges49 bronze badges asked Aug 17, 2011 at 7:25 Eugene PetrovEugene Petrov 6511 gold badge6 silver badges14 bronze badges 1
  • 1 Just curious, but did you try with c instanceof a? That would work in Javascript. – troelskn Commented Aug 17, 2011 at 17:44
Add a ment  | 

2 Answers 2

Reset to default 6

(Based on @troelskn 's ment)

http://jsfiddle/miriam/ugQHB/

c instanceof A

returns true.

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

本文标签: javascriptHow to check whether one class is inhereted of another classStack Overflow