2.1.8 [ECMA-262/5] Section 15.3.4.2, Function.prototype.toString ()

V0008:

The specification states:

 An implementation-dependent representation of the function is returned. This representation has the syntax of a FunctionDeclaration. Note in particular that the use and placement of white space, line terminators, and semicolons within the representation String is implementation-dependent.

IE9 Mode, IE10 Mode, IE11 Mode, and EdgeHTML Mode (All Versions)

The following variations apply:

  • The implementation-dependent representation has the syntax of a FunctionExpression function object.

  • The representation of a function that is implemented by using ECMAScript code is the exact sequence of characters that is used to define the function. The first character of the representation is the letter "f" of function, and the final character is the final closing brace ("}") of the function definition. However, if the function is defined by using a FunctionExpression function object that is immediately surrounded by one or more levels of grouping operators ([ECMA-262/5] section 11.1.6), the first character of the representation is the opening parenthesis ("(") of the innermost such grouping operator and the final character is the closing parenthesis (")") of the innermost such grouping operator.

    If the function is created by the Function constructor ([ECMA-262/5] section 15.3.2.1), the representation of the function consists of the following elements in this order:

    1. The string "function anonymous("

    2. The value of P that is used in step 16 of the [ECMA-262/5] section 15.3.2.1 algorithm that created the function

    3. The string ") {"

    4. A <LF> character

    5. The value of body that is used in step 16 of the algorithm

    6. A <LF> character and a closing brace ("}").

      If the function is not implemented by using ECMAScript code (that is, it is a built-in function or a host object function), the FunctionBody function object of the generated representation does not conform to ECMAScript syntax. Instead, the FunctionBody function object consists of the string "[native code]".

      The format of the representation that is generated has the syntax of a standard ECMAScript, Fifth Edition FunctionExpression function object rather than a FunctionDeclaration function object. For anonymous functions that are created through a FunctionExpression function object that does not include the optional Identifier, the generated syntax does not include the optional Identifier and does not conform to the base standard’s definition of FunctionExpression.