In traditional object-pascal all classes inherit from a type called TObject. Quartex Pascal likewise supports this and most of your object pascal code will inherit from that.

But when it comes to interfacing directly with JavaScript libraries, the dependency on TObject is thankfully optional.


When you inherit your classes from TObject the compiler generates VMT (virtual method table) data for the object instances. This is the "magic glue" that makes traditional OOP and polymorphism possible under JavaScript. The way our VMT is organized is not really compatible with what JavaScript libraries expect, which is typically a clean object structure with named fields, sub structures and values.


The solution was to introduce an optional ancestor called JObject. This ancestor informs the compiler that no VMT or OOP functionality should be generated, which means no polymorphism is possible. It basically reduces the functionality of the class to that of vanilla JavaScript objects.


So instead of writing:


TMyClass = class( TObject )

end;


You instead write:


TMyClass = class( JObject )

end;


Just like TObject you can inherit from classes based on JObject, but these classes are limited to ordinary methods, properties and fields. You cannot have abstract methods, override methods, or have duplicate names in the inheritance chain. Behind the scenes there is only pseudo inheritance for these class types, where the compiler keeps track of everything and duplicates the ancestor content into the successor. The inheritance is simply there to make writing large wrapper units for JS libraries sane.