[Pas2js] Class constant with "external" class

Michael Van Canneyt michael at freepascal.org
Sat Jan 27 12:40:53 CET 2018



On Sat, 27 Jan 2018, Mattias Gaertner wrote:

> On Sat, 27 Jan 2018 11:23:14 +0100 (CET)
> Michael Van Canneyt <michael at freepascal.org> wrote:
>
>> [...]
>> Yes, but how would I define this in javascript ? 
>> Not add it to a prototype ?
>
> My remark was about JS objects created by Object.create(aclass).
>
> When an object is created via the 'new' operator, it uses the
> 'prototype' as ancestor, which corresponds to
> Object.create(aclass.prototype). In that case a class-var should
> either access the aclass.prototype.classvar or forbid it.
>
> The question is how pas2js should recognize that. 
> a) When a class descends from JS 'Function'
> b) When the class has a constructor 'New'.
> c) both
>
> What do you think?

It seems to me that the answer is c)

Michael.



More information about the Pas2js mailing list