Where in spec does it explain why setting the value of an existing property will change its [[Enumerable]] attribute.

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Aug 17 05:40:53 PDT 2011


On Aug 16, 2011, at 9:44 PM, John-David Dalton wrote:

> So @kitcambridge and I were talking spec and started trying to find in
> spec something that explains why something like:
> 
> Array.prototype.reduce which is by default  { [[Writable]]: true,
> [[Enumerable]]: false, [[Configurable]]: true } will change to
> [[Enumerable]]: true when:
> 
> Array.prototype.reduce = function() {…};


Why do you think this should change [[Enmerable]] to true??

> 
> So far we have struck out.
> In ES3 we found 8.6.2.2 [[Put]](P, V)
> http://bclary.com/2004/11/07/#a-8.6.2.2
> and its step 4:
> 4. Set the value of the property to V. The attributes of the property
> are not changed.
> 
> And then we dug into ES5.1 and its [[Put]]
> http://es5.github.com/#x8.12.5
> and its step step 3a which leads to [[DefineOwnProperty]] with a Desc
> of {[[Value]]: V} and its step 10b to 12, then 13.
> 
> but couldn't find where it stated changing the [[Enumerable]] attribute.
> 
> Would you all help point to where this is defined in spec?

It isn't.  Simply assigning a new value to an already existing own data property isn't supposed to change any attributes.

Allen



More information about the es-discuss mailing list