[Pas2js] Object literals?

Michael Van Canneyt michael at freepascal.org
Sun Jun 3 08:38:09 CEST 2018



On Sun, 3 Jun 2018, Mattias Gaertner wrote:

> On Sun, 3 Jun 2018 07:44:22 +0200
> Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
>
>> On Sun, 3 Jun 2018 09:55:41 +0700
>> Ryan Joseph <ryan at thealchemistguild.com> wrote:
>> 
>> > can you make object literals (I think that’s what they’re called)/associative arrays/dictionaries in pas2js? Somehow I didn’t come across that in the short time I used it. I know I can make a record but it should be possible using JSArray I thought (I was told the index of an array can be a string or other type).
>> > 
>> > d = { items: [], text: '’ }; 
>> 
>> Maybe this helps:
>> http://wiki.freepascal.org/pas2js#Create_simple_JS_objects_with_the_new_function
>
> Btw, Michael, what do you think of adding a similar function with
> varargs instead of TJSValueDynArray? Then the [] can be omitted.
> Of course it cannot be named 'new'. Perhaps "NewJSObj"?

Personally, I don't see the need. 
I don't mind the [], to me they give a clear indication of what is happening.

But if you want to add it: Sure, please do...

Michael.


More information about the Pas2js mailing list