global function declarations and predefined global properties

Brendan Eich brendan at
Thu Jul 8 10:42:45 PDT 2010

On Jul 8, 2010, at 10:40 AM, Allen Wirfs-Brock wrote:

> I think a set of user facing semantics that strike a balance between the ES1-3 behavior and the new ES5 functionality would  be something along the lines of:
> 1) If a global FunctionDeclaration has the same name as an existing property of the global object
>     a) If the preexisting property is /configurable/ then the property is redefined using as a data property with FunctionDeclaration default attributes
>     b) if the preexisting property is a /non-configurable/ data property whose attributes are the same as FunctionDeclaration default attributes then the value of the property is set to the function object.
>     c) otherwise the FunctionDeclaration is ignored and a TypeError exception is thrown.
> Since the “error” case is new to ES5 it is reasonable to define it as throwing.  This warns developers that they have stumbled upon something such as declaring a function named undefined that has changed from ES3.


> I don’t think it would be reasonable as part of an errata to do all the algorithm modifications to chapter 10 that would be necessary to express the above.  However, I do think we could slip the above rules as prose into step 5 of 10.5.

You rock! ;-)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es5-discuss mailing list