Skip to content

Should anonymous functions get a name data property? #1049

@ajklein

Description

@ajklein

ES2015 and later give a name property to named functions (whether named via declaration, expression, or name inference). Anonymous functions aren't given one, presumably with the expectation that name lookups will read through to Function.prototype.name (which is an empty string).

Yet engines have legacy behavior here:

> eshost -e '(() => {}).hasOwnProperty("name")' // same result for function(){}
#### v8
true

#### jsc
true

#### spidermonkey
true

#### chakra
false

I'd propose that there'd be little downside to specifying this behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    has consensusThis has committee consensus.normative changeAffects behavior required to correctly evaluate some ECMAScript source textweb reality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions