Function.prototype.toString Change Proposal

Oliver Hunt oliver at
Fri Sep 18 00:26:22 PDT 2009

> How?
> javascript: alert(function(){})
> Safari 4 elerts:
> "function () {}"
> The current specification doesn't allow that.
> Why not?
> The current specification requires the result of
> Function.prototype.toString to be a FunctionDeclaration and
> "function(){}" is not  a FunctionDeclaration representation.
> So it seems you want Safari to change, but the specification to
> remain. I would have to disagree, as that might break sites (and for
> absolutely no good reason).
> I propose that browsers today stay as they are (Safari, Firefox,
> Chrome, IE, etc all produce that result).  The specification should
> allow them to do so.

I was referring mainly to the changes in representation of the native  
functions sorry.  I'm also unsure whether it would be possible to add  
'anonymous' as a function name.  I vaguely recall one site failing  
when we removed the space on either side of the ()'s so that does  
worry me.  I also believe the eBay (at least in the past) did string  
replacement on the result of function.toString to create new functions  
which caused us a headache back then as well.

> Garrett


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

More information about the es-discuss mailing list