Closely related to anonymous records is an even more powerful feature: anonymous classes (also referred to as "anonymous objects" ). Just like anonymous records, an anonymous class allows you to define a data structure and create an instance of it at the same time, right in your var block. It uses the class keyword instead of record.


The syntax is just as simple:


var a := class

 first: int32 := 12;

 function test: boolean;

 begin

   result := first > 0;

 end;

end;


While anonymous classes and records both map to plain JavaScript objects, anonymous classes have two critical advantages:


They Include Methods: This is the most obvious difference. An anonymous class can contain not only data fields (like first) but also functions and procedures (like test) .


Name Preservation (No Obfuscation): This is the most important technical difference. The Quartex Pascal compiler's obfuscater (which shortens variable names to reduce file size) is instructed to not garble the field and method names inside an anonymous class.