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.2 crxOop.isClassChaining

crxOop.isClassChaining can be used during run time to inspect if pure instances of a class can be casted to another class. The function behaves exactly like crxOop.isClassExtending, but will return true if a class is checked against itself. If any of the parameters is not a valid class definition object, or registered class name, crxOop.isClassChaining will issue a fatal error.

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

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

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

console.log((crxOop.isClassChaining("ExampleClass1", "ExampleClass2") ? "true" : "false"));
console.log((crxOop.isClassChaining("ExampleClass2", "ExampleClass1") ? "true" : "false"));
console.log((crxOop.isClassChaining("ExampleClass3", "ExampleClass2") ? "true" : "false"));
console.log((crxOop.isClassChaining("ExampleClass3", "ExampleClass3") ? "true" : "false"));
console.log((crxOop.isClassChaining("ExampleClass1", "ExampleClass3") ? "true" : "false"));
false
true
true
true
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.isClassChaining("ExampleClass1", "ExampleClass2") ? "true" : "false"));
console.log((crxOop.isClassChaining("ExampleClass2", "ExampleClass1") ? "true" : "false"));
console.log((crxOop.isClassChaining("ExampleClass3", "ExampleClass2") ? "true" : "false"));
console.log((crxOop.isClassChaining("ExampleClass3", "ExampleClass3") ? "true" : "false"));
console.log((crxOop.isClassChaining("ExampleClass1", "ExampleClass3") ? "true" : "false"));
false
true
true
true
false