name property for built-in functions??

Brendan Eich brendan at
Tue Mar 3 15:25:26 PST 2009

On Mar 3, 2009, at 2:39 PM, Maciej Stachowiak wrote:

> Surprising though it may be, it seems that (new Function).name ===  
> "anonymous" may be relevant to Web compatibility. We changed  
> JavaScriptCore to match SpiderMonkey on this as a result of this bug:

I can't reach that hostname, but 

BTW, the ability to write a program whose entire source is "function  
() {}" is an old, pre-ES3 feature of SpiderMonkey that people *still*  
depend on, especially when using eval (not new Function) to generate a  
lambda from source.

Per ES3 this should be a syntax error as Darin Adler pointed out in  
the bug, but we have had to keep compatibility with  
what came before ES3 on this point. There's an API option  
(JSOPTION_ANONFUNFIX) to make this case an error per spec.

> I strongly suspect code also depends on (function(){}).name==="" but  
> I don't have a clear-cut example handy.

I voiced the same suspicion. I didn't know any web site depending on  
Function().name == "anonymous", though. What a world!


More information about the Es-discuss mailing list