ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.6 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://jskatas.org/katas/es6/language/function-api/name/ |
| Last Crawled | 2026-03-21 19:14:17 (19 days ago) |
| First Indexed | 2023-10-16 02:24:15 (2 years ago) |
| HTTP Status Code | 200 |
| Meta Title | function API – `function.name` | JavaScript Katas |
| Meta Description | A kata to (re-)learn about function API | `function.name` | The `name` property is "descriptive of the function" the specification says. | 8 tests to solve | Difficulty Level: INTERMEDIATE |
| Meta Canonical | null |
| Boilerpipe Text | The
name
property is "descriptive of the function" the specification says.
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
function functionDeclaration() {}
const functionName = functionDeclaration.length;
assert.equal(functionName, 'functionDeclaration');
GIVEN a function expression
WHEN reading the
name
THEN it is the name of the variable holding the function
const fnExpression = function() {};
assert.equal(functionExpression.name, 'functionExpression');
WHEN assigning the function to a different variable THEN the name stays the initial variable's name
let firstFnExpression = function() {};
let secondName = function() {};
firstFnExpression = 0; // set it to something else than a function, just to make sure.
assert.equal(secondName.name, 'firstFnExpression');
WHEN reading the
name
THEN it is the name of the variable holding the function
const arrowFunction = {};
assert.equal(arrowFunction.name, 'arrowFunction');
special cases
WHEN binding a function THEN the bound-function's name gets prefixed with "bound"
const myFn = () => {};
const weBoundFn = myFn.bind(null);
const expected = 'weBoundFn';
assert.equal(weBoundFn.name, expected);
WHEN creating a
new Function
instance THEN the name is "anonymous"
const fn = () => {};
assert.equal(fn.name, 'anonymous');
WHEN reading the name of a getter THEN it is prefixed with "get"
const obj = { set x(_) {} };
assert.equal(Object.getOwnPropertyDescriptor(obj, 'x').get.name, 'get x');
WHEN reading the name of a setter THEN it is prefixed with "set"
const obj = {};
assert.equal(Object.getOwnPropertyDescriptor(obj, 'x').set.name, 'set x');
Links
spec
docs
The specification text, this property was introduced with this version of JavaScript.
mdn
docs
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
basics
function binding
Async Function
basics
Difficulty Level
INTERMEDIATE
First Published
15 October 2023
Stats
8 tests to solve |
| Markdown | [jskatas.org Continuously Learn JavaScript. Your Way.](https://jskatas.org/)
- [](https://mastodontech.de/@wolframkriesing "Feedback welcome on Mastodon")
- [Katas](https://jskatas.org/katas/)
- [Blog](https://jskatas.org/blog/)
- [About](https://jskatas.org/about/)
- [🇺🇦](https://julenka.org/)
- [All katas](https://jskatas.org/katas/) »
- ECMAScript 6 / ES2015 »
- function API »
- \`function.name\`
# function API: `function.name`
The `name` property is "descriptive of the function" the specification says.
## 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
function functionDeclaration() {} const functionName = functionDeclaration.length; assert.equal(functionName, 'functionDeclaration');
### GIVEN a function expression
WHEN reading the `name` THEN it is the name of the variable holding the function
const fnExpression = function() {}; assert.equal(functionExpression.name, 'functionExpression');
WHEN assigning the function to a different variable THEN the name stays the initial variable's name
let firstFnExpression = function() {}; let secondName = function() {}; firstFnExpression = 0; // set it to something else than a function, just to make sure. assert.equal(secondName.name, 'firstFnExpression');
WHEN reading the `name` THEN it is the name of the variable holding the function
const arrowFunction = {}; assert.equal(arrowFunction.name, 'arrowFunction');
### special cases
WHEN binding a function THEN the bound-function's name gets prefixed with "bound"
const myFn = () =\> {}; const weBoundFn = myFn.bind(null); const expected = 'weBoundFn'; assert.equal(weBoundFn.name, expected);
WHEN creating a `new Function` instance THEN the name is "anonymous"
const fn = () =\> {}; assert.equal(fn.name, 'anonymous');
WHEN reading the name of a getter THEN it is prefixed with "get"
const obj = { set x(\_) {} }; assert.equal(Object.getOwnPropertyDescriptor(obj, 'x').get.name, 'get x');
WHEN reading the name of a setter THEN it is prefixed with "set"
const obj = {}; assert.equal(Object.getOwnPropertyDescriptor(obj, 'x').set.name, 'set x');
## Links
spec docs [The specification text, this property was introduced with this version of JavaScript.](https://262.ecma-international.org/6.0/#sec-function-instances-name)
mdn docs [The MDN pages describing this property, easy to read with examples.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
## Required Knowledge
- [basics](https://jskatas.org/katas/es6/language/arrow-functions/basics/) (Arrow functions)
- [\`const\` declaration](https://jskatas.org/katas/es6/language/block-scoping/const/) (Block scope)
## Related Katas
### function API
- [`function.length` (as introduced in ES1)](https://jskatas.org/katas/es1/language/function-api/length/)
- [`function.bind()`](https://jskatas.org/katas/es5/language/function-api/bind/)
- [`function.length` (with ES5 features)](https://jskatas.org/katas/es5/language/function-api/length/)
- [`function.length` (with ES6 features)](https://jskatas.org/katas/es6/language/function-api/length/)
- `function.name`
### Arrow functions
- [basics](https://jskatas.org/katas/es6/language/arrow-functions/basics/)
- [function binding](https://jskatas.org/katas/es6/language/arrow-functions/binding/)
### Async Function
- [basics](https://jskatas.org/katas/es8/language/async-functions/basics/)
## Difficulty Level
INTERMEDIATE
## First Published
15 October 2023
## Stats
8 tests to solve
## How does it work?
- Open one test (if it didn't auto-open yet)
- Read the description above the code
- Make the tests pass
- Do **not change the `assert`** line(s)
- Move on to the next test
Solve this kata ►️
## Settings
- Open 1st test on page load? Will have an effect when opening the next kata page.
- Open next test on green? When turned on, the next test automatically opens when you made the test pass (on green). And the next test is centered on the screen, so you can start working on it right away.
## Pages
- [](https://mastodontech.de/@wolframkriesing "Feedback welcome on Mastodon")
- [Katas](https://jskatas.org/katas/)
- [Blog](https://jskatas.org/blog/)
- [About](https://jskatas.org/about/)
- [🇺🇦](https://julenka.org/)
## Contact
- [LinkedIn](https://www.linkedin.com/in/wolframkriesing/)
- [Mastodon](https://mastodontech.de/@wolframkriesing)
- [Email me](mailto:w+through-jskatas-blog-footer-contact@kriesing.de)
- Twitter
- @jskatas on [twitter](https://twitter.com/jskatas)
## Source Code
- Page code at [codeberg.org](https://codeberg.org/wolframkriesing/jskatas.org)
- Kata's at [codeberg.org](https://codeberg.org/wolframkriesing/javascript-katas)
☰
- [](https://mastodontech.de/@wolframkriesing "Feedback welcome on Mastodon")
- [Katas](https://jskatas.org/katas/)
- [Blog](https://jskatas.org/blog/)
- [About](https://jskatas.org/about/)
- [🇺🇦](https://julenka.org/) |
| Readable Markdown | The `name` property is "descriptive of the function" the specification says.
## 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
function functionDeclaration() {} const functionName = functionDeclaration.length; assert.equal(functionName, 'functionDeclaration');
### GIVEN a function expression
WHEN reading the `name` THEN it is the name of the variable holding the function
const fnExpression = function() {}; assert.equal(functionExpression.name, 'functionExpression');
WHEN assigning the function to a different variable THEN the name stays the initial variable's name
let firstFnExpression = function() {}; let secondName = function() {}; firstFnExpression = 0; // set it to something else than a function, just to make sure. assert.equal(secondName.name, 'firstFnExpression');
WHEN reading the `name` THEN it is the name of the variable holding the function
const arrowFunction = {}; assert.equal(arrowFunction.name, 'arrowFunction');
### special cases
WHEN binding a function THEN the bound-function's name gets prefixed with "bound"
const myFn = () =\> {}; const weBoundFn = myFn.bind(null); const expected = 'weBoundFn'; assert.equal(weBoundFn.name, expected);
WHEN creating a `new Function` instance THEN the name is "anonymous"
const fn = () =\> {}; assert.equal(fn.name, 'anonymous');
WHEN reading the name of a getter THEN it is prefixed with "get"
const obj = { set x(\_) {} }; assert.equal(Object.getOwnPropertyDescriptor(obj, 'x').get.name, 'get x');
WHEN reading the name of a setter THEN it is prefixed with "set"
const obj = {}; assert.equal(Object.getOwnPropertyDescriptor(obj, 'x').set.name, 'set x');
## Links
spec docs [The specification text, this property was introduced with this version of JavaScript.](https://262.ecma-international.org/6.0/#sec-function-instances-name)
mdn docs [The MDN pages describing this property, easy to read with examples.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)
## Required Knowledge
- [basics](https://jskatas.org/katas/es6/language/arrow-functions/basics/) (Arrow functions)
- [\`const\` declaration](https://jskatas.org/katas/es6/language/block-scoping/const/) (Block scope)
## Related Katas
### function API
- [`function.length` (as introduced in ES1)](https://jskatas.org/katas/es1/language/function-api/length/)
- [`function.bind()`](https://jskatas.org/katas/es5/language/function-api/bind/)
- [`function.length` (with ES5 features)](https://jskatas.org/katas/es5/language/function-api/length/)
- [`function.length` (with ES6 features)](https://jskatas.org/katas/es6/language/function-api/length/)
- `function.name`
### Arrow functions
- [basics](https://jskatas.org/katas/es6/language/arrow-functions/basics/)
- [function binding](https://jskatas.org/katas/es6/language/arrow-functions/binding/)
### Async Function
- [basics](https://jskatas.org/katas/es8/language/async-functions/basics/)
## Difficulty Level
INTERMEDIATE
## First Published
15 October 2023
## Stats
8 tests to solve |
| Shard | 71 (laksa) |
| Root Hash | 18437570319587690671 |
| Unparsed URL | org,jskatas!/katas/es6/language/function-api/name/ s443 |