title: Function.prototype.toString revision
status: proposal
stage: 1
contributors: Michael Ficarra
toc: true

Introduction

Goals

The original goals of this proposal were

The revised goals of this proposal also include

(19.2.3.5) Function.prototype.toString()

When the `toString` method is called with an object _func_ as its *this* value, the following steps are taken:

1. If _func_ is a Bound Function exotic object, then 1. Return an implementation-dependent String source code representation of _func_. The representation must conform to the rules below. It is implementation dependent whether the representation includes bound function information or information about the target function. 1. If Type(_func_) is Object and is either a built-in function object or has an [[ECMAScriptCode]] internal slot, then 1. Return an implementation-dependent String source code representation of _func_. The representation must conform to the rules below. 1. Throw a *TypeError* exception.

`toString` Representation Requirements:

1. If _func_ is a Bound Function exotic object, then return an implementation-dependent string source code representation of _func_. It is implementation dependent whether the representation includes bound function information or information about the target function. The representation must conform to the `toString` Representation Requirements below. 1. If Type(_func_) is Object and IsCallable(_func_) is *true*, then return an implementation-dependent string source code representation of _func_. The representation must conform to the `toString` Representation Requirements below. 1. Throw a *TypeError* exception.

`toString` Representation Requirements:

NativeFunction : `function` BindingIdentifier? `(` FormalParameters `)` `{` `[` `native` `code` `]` `}`

(14.3) Method Definitions

Syntax

MethodDefinition[Yield] : PropertyName[?Yield] `(` StrictFormalParameters `)` `{` FunctionBody `}` GeneratorMethod[?Yield] `get` PropertyName[?Yield] `(` `)` `{` FunctionBody `}` `set` PropertyName[?Yield] `(` PropertySetParameterList `)` `{` FunctionBody `}` MethodDefinition[Yield] : PropertyName[?Yield] `(` StrictFormalParameters `)` `{` FunctionBody `}` GeneratorMethod[?Yield] Getter[?Yield] Setter[?Yield] Getter[Yield] : `get` PropertyName[?Yield] `(` `)` `{` FunctionBody `}` Setter[Yield] : `set` PropertyName[?Yield] `(` PropertySetParameterList `)` `{` FunctionBody `}` Other existing references to the 3rd and 4th alternatives in the MethodDefinition grammar will need to be changed.