Setting up (non-index) properties of arrays

Brendan Eich brendan at mozilla.org
Sat Aug 4 13:26:46 PDT 2012


The desugaring in the wiki proposal must not be observable.

Separately, we've long entertained extending array literals to encompas 
ad-hoc properties (expandos). Also the dict strawman wants [a:1,b:2] 
syntax. I think expandos on arrays are rare enough that dicts should 
win, if it comes down to a future-proofing fight.

/be

Axel Rauschmayer wrote:
> As an example, a template string call site ID would be constructed as 
> follows:
>
>     const callSiteId1234 = do {
>         let literalParts = ['lit1\n', ' lit2 ', ''];
>         literalParts.raw = ['lit1\\n', ' lit2 ', ''];
>         literalParts
>     };
>
> How about the following abbreviation?
>
>     const callSiteId1234 = ['lit1\n', ' lit2 ', '', raw: ['lit1\\n', ' 
> lit2 ', '']];
>
> Not sure it’s a frequent-enough use case, though. Mustache would be 
> nice here, or one could use Underscore:
>
>     const callSiteId1234 = _.extend(['lit1\n', ' lit2 ', ''], 
> {raw: ['lit1\\n', ' lit2 ', '']});
>
> -- 
> Axel Rauschmayer
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list