The name
property tries to provide a useful name for a function
GIVEN a function declaration
WHEN reading the name
property THEN it is the name of the function
GIVEN a function expression
WHEN reading the name
THEN it is the name of the variable holding the function
WHEN assigning the function to a different variable THEN the name stays the initial variable's name
WHEN reading the name
THEN it is the name of the variable holding the function
special cases
WHEN binding a function THEN the bound-function's name gets prefixed with "bound"
WHEN creating a new Function
instance THEN the name is "anonymous"
WHEN reading the name of a getter THEN it is prefixed with "get"
WHEN reading the name of a setter THEN it is prefixed with "set"
Links
The specification text, this property was introduced with this version of JavaScript.
The MDN pages describing this property, easy to read with examples.
Required Knowledge
- basics (Arrow functions)
- `const` declaration (Block scope)
Related Katas
function API
function.length
(as introduced in ES1)function.bind()
function.length
(with ES5 features)function.length
(with ES6 features)function.name
Arrow functions
Async Function
Difficulty Level
INTERMEDIATE
First Published
15 October 2023
Stats
8 tests to solve