CrxOop CrxOop: Bringing Object Oriented Programming, and Proper Prototype Based Programming, To Javascript
The aim of the library documented below is to provide developers with a solution to allow development using interfaces and classes as they are known in other object oriented programming (OOP) languages such as C++, C#, Java and PHP. Further more, V1.4 introduces structures, a generalization of the concept of prototypal inheritance, known here as POBP.
Subject
Body*
Email
SUBMIT CLOSE
Menu

7.1 crxOop.isClassExtending

crxOop.isClassExtending can be used to inspect during run time if a class, not an instance, extends another class. If any of the parameters is not a valid class definition object, or registered class name, crxOop.isClassExtending will issue a fatal error.

JS (Tree)
crx_registerClass("ExampleClass1",
{
});

crx_registerClass("ExampleClass2",
{
   EXTENDS: "ExampleClass1"
});

crx_registerClass("ExampleClass3",
{
   EXTENDS: "ExampleClass2"
});

console.log((crxOop.isClassExtending("ExampleClass1", "ExampleClass2") ? "true" : "false"));
console.log((crxOop.isClassExtending("ExampleClass2", "ExampleClass1") ? "true" : "false"));
console.log((crxOop.isClassExtending("ExampleClass3", "ExampleClass2") ? "true" : "false"));
console.log((crxOop.isClassExtending("ExampleClass3", "ExampleClass3") ? "true" : "false"));
console.log((crxOop.isClassExtending("ExampleClass1", "ExampleClass3") ? "true" : "false"));
false
true
true
false
false
JS (Verbose)
crx_registerClass("ExampleClass1",
{
   "VERBOSE": 1
});

crx_registerClass("ExampleClass2",
{
   "VERBOSE": 1,
   "extends": "ExampleClass1"
});

crx_registerClass("ExampleClass3",
{
   "VERBOSE": 1,
   "extends": "ExampleClass2"
});

console.log((crxOop.isClassExtending("ExampleClass1", "ExampleClass2") ? "true" : "false"));
console.log((crxOop.isClassExtending("ExampleClass2", "ExampleClass1") ? "true" : "false"));
console.log((crxOop.isClassExtending("ExampleClass3", "ExampleClass2") ? "true" : "false"));
console.log((crxOop.isClassExtending("ExampleClass3", "ExampleClass3") ? "true" : "false"));
console.log((crxOop.isClassExtending("ExampleClass1", "ExampleClass3") ? "true" : "false"));
false
true
true
false
false

Notice how a class is not extending itself. If you also want this case to return true, check the next section on crxOop.isClassChaining().