[Pas2js] Class constant with "external" class

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Jan 27 11:08:31 CET 2018


On Sat, 27 Jan 2018 10:46:23 +0100 (CET)
Michael Van Canneyt <michael at freepascal.org> wrote:

>[...]
> Provided it works, of course. It's not clear to me what a class var would
> be in Javascript.

Same as with normal classes. It is accessing the class instead of the
instance. For example:

type
TForeignObject = class external 'ForeignObject'
  class var Counter: integer;
end;

var o: TForeignObject;

o.Counter:=3;

becomes:

ForeignObject.Counter = 3;

Now all TForeignObject instances have Counter = 3.

Mattias


More information about the Pas2js mailing list