(function foo(){}).propertyIsEnumerable("prototype"): true or false?

Brendan Eich brendan at mozilla.com
Fri Sep 4 10:24:38 PDT 2009


On Sep 3, 2009, at 8:48 PM, Allen Wirfs-Brock wrote:

>> ES3, 15.3.5.2, says the prototype property of function instances is  
>> enumerable.
>> ES5, 13.2 step 17, says the prototype property of function  
>> instances is not enumerable.
>
> ES5, 15.3.5.2 also says non-enumerable  so at least it is internally  
> consistent.
> I don't recall this specific change but tomorrow I'll look at some  
> back drafts and see if I can identify when/why the change was made.
> Non-enumerable seems like the preferable value but I don't think we  
> would have made an incompatible change unless we both thought the  
> old definition was "wrong" and the actual web was inconsistent.  
> Since Chrome wasn't yet around when some of these decisions were  
> made 3 out of 4 major browser implementations were probably non- 
> enumerable at the time.

Not something I noticed either, but it gets rid of an annoying  
difference between built-in constructors and user-defined functions:

js> for(i in Date)print(i)
js> function MyDate(){}
js> for(i in MyDate)print(i)
prototype

I hope it doesn't break anything on the web. It could, because using  
for-in to inspect properties and extend base objects with copies of  
them is standard practice (Doug's "Swiss inheritance", search for  
"Swiss" in http://www.cosmik.com/aa-october99/stan_freberg.html).

/be



More information about the es-discuss mailing list