Function.prototype.toString spec

Peter Michaux petermichaux at gmail.com
Sat Dec 1 15:23:28 PST 2007


ECMA-262 3rd

== section 15.3.4.2 ==

Function.prototype.toString returns a representation with syntax of
FunctionDeclaration


== section13 ==

FunctionDeclaration:
  function Identifier ( FormalParameterList_opt )  { FunctionBody }

FunctionExpression:
  function Identifier_opt ( FormalParameterList_opt )  { FunctionBody }


== Firefox results ==

alert((function(){}).toString())

// outputs

function () {
}

Note there is no Identifier in this output and an identifier is
required in FunctionDeclaration syntax. Should
Function.prototype.toString be specified to return a representation
with FunctionExpression syntax?

Thanks,
Peter



More information about the Es4-discuss mailing list