ES4 draft: Object initializers

Lars Hansen lhansen at
Thu Mar 20 17:43:05 PDT 2008

Thanks for pointing some of these out, Brendan did the same.  This is
already legal to define catch-alls:

  { var meta::get: function () { ... } }

Ditto for meta::set, meta::has, meta::delete, meta::invoke.  A bit wordy
though, and since it's already in (unless we special-case banish it for
I don't know what good reasons) then we can probably support it with
simple syntax, this is a suggestion:

  { get() { ... } }

As for dontenum, IMO use a namespace or a fixture.  (If you're building
a prototype object then presumably you'd like the methods not to be
deletable as well; 'var' or 'const' is a cheap fix in that case.)

As for prototype, we're discussing it.  A possible fix is to allow the
name 'meta::prototype' to be used in the object initializer (only!) to
signify initialization of the prototype.  (You won't be able to read
that value back with the syntax.)


> -----Original Message-----
> From: es4-discuss-bounces at 
> [mailto:es4-discuss-bounces at] On Behalf Of liorean
> Sent: 20. mars 2008 17:13
> To: es4-discuss at
> Subject: Re: ES4 draft: Object initializers
> On 21/03/2008, Lars Hansen <lhansen at> wrote:
> > I've attempted to sum up everything we have decided about object  
> > initializers (aka object literals).  A short draft spec is included.
> >  Comments welcome from everyone, especially from ES4 WG members who 
> > might  remember about things I've forgotten, or correct 
> misunderstandings.
> Just a few ideas, I think there's a few declarative features 
> I'd like to see added:
> - I'd *really* like to see some declarative syntax for 
> setting {DontEnum} flag on properties in object initialisers.
> - A declarative way to set catch-alls.
> - A declarative way to set the [[Call]] property.
> - And maybe declarative way to set the [[Prototype]] 
> property. (This would of course be const.)
>     var
>         a={
>             dontenum toString: function()'[object customObj]'
>             },
>         b={
>             [[Prototype]]: a,
>             [[Call]]: function()...,
>             get *: function(propname)...,
>             set *: function(propname, value)...,
>             ...
>         };
> The brackets for syntax would from what I can tell work here, 
> since they are syntax errors in ES3. Or using some double 
> keyword syntax I guess.
> --
> David "liorean" Andersson
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at

More information about the Es4-discuss mailing list