Extended Object Literals to review

P T Withington ptw at pobox.com
Mon Mar 14 10:32:44 PDT 2011


On 2011-03-13, at 18:15, Juan Ignacio Dopazo wrote:

> @Brendan My mistake was thinking that setting enumerable to false also made
> it return false on hasOwnProperty().
> 
> The idea behind it was to be able to walk down the prototype chain by doing
> o.constructor.prototype.contructor.proto... But then I realized that's not
> the case even in today's javascript.

I agree that we need this.  Can something like:

>> On Sat, Mar 12, 2011 at 4:36 PM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
>> good point, the desugaring should be:
>> 
>> function c() {};
>> c.prototype=Object.create(s,protoype,{'constructor': { value:c, enumerable: false, writable: false, configurable:false}});

make 'walking the prototype chain' work _without_ giving each instance a constructor property?

  see = new c();

  see.constructor => c
  see.constructor.prototype.constructor => s

?

ES3 does not have the luxury of Object.create, so to get the same effect I _have_ put the constructor value in each instance.  This is what OpenLaszlo does today.  I'm looking forward to the day when I won't have to any more.

It seems the desugaring quoted above should do this for you (assuming `s` is similarly defined).


More information about the es-discuss mailing list