ℹ️ 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 | 1.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://www.educative.io/answers/what-is-functionname-in-javascript |
| Last Crawled | 2026-03-06 12:51:40 (1 month ago) |
| First Indexed | 2025-01-24 17:13:15 (1 year ago) |
| HTTP Status Code | 200 |
| Content | |
| Meta Title | What is function.name in JavaScript? |
| Meta Description | Contributor: Programming Bytes |
| Meta Canonical | null |
| Boilerpipe Text | console.log("\Normal Function")
console.log("-------------------------")
function test(){ }
console.log(test.toString(), "-- name -- ", test.name);
let fn1 = test;
console.log(fn1.toString(), "-- name -- ", fn1.name);
let fn2 = function(){ }
console.log(fn2.toString(), "-- name -- ", fn2.name);
console.log("\nFunction Expression")
console.log("-------------------------")
let fn3 = function f() { }
console.log(fn3.toString(), "-- name -- ", fn3.name);
console.log("\nObject function")
console.log("-------------------------")
let obj = { fobj() { } }
console.log(obj.fobj.toString(), "-- name -- ", obj.fobj.name);
console.log("\n with new Function constructor")
console.log("-------------------------")
let fn4 = (new Function); // "anonymous"
console.log(fn4.toString(), "-- name -- ", fn4.name);
console.log("\n Arrow function")
console.log("-------------------------")
let arrow = ( () => {} ).name;
console.log("Arrow function name", arrow); // empty string
console.log("((){}).name => ", ( () => {} ).name); // empty string
console.log("\n Bind Function")
console.log("-------------------------")
function fn5() { };
let bindFn = fn5.bind({});
console.log(bindFn.toString(), "-- name -- ", bindFn.name); |
| Markdown | Explore
EXPLORE THE CATALOGSupercharge your career with 700+ hands-on courses
View All Courses
Python
Java
JavaScript
C
React
Docker
Vue JS
R
Web Dev
DevOps
AWS
C\#
LEARNING TOOLSExplore the industry's most complete learning platform
CoursesLevel up your skills
Skill PathsAchieve learning goals
ProjectsBuild real-world applications
Mock InterviewsNewAI-Powered interviews
Personalized PathsGet the right resources for your goals
LEARN TO CODE
Check out our beginner friendly courses.
Pricing
For Business
Resources
[NewsletterCurated insights on AI, Cloud & System Design](https://www.educative.io/newsletter)
[BlogFor developers, By developers](https://www.educative.io/blog)
[Free CheatsheetsDownload handy guides for tech topics](https://www.educative.io/cheatsheets)
[AnswersTrusted answers to developer questions](https://www.educative.io/answers)
[GamesSharpen your skills with daily challenges](https://www.educative.io/games)
Search
Courses
Log In
Join for free
# What is function.name in JavaScript?
The **`name` property** of the `Function` object is used to get the function’s name.
`name` is a read-only property of the `Function` object.
## Syntax
```
function.name
```
## Code
Let’s observe several functions and use `function.name` to return their name.
```
console.log("\Normal Function")console.log("-------------------------")function test(){ }console.log(test.toString(), "-- name -- ", test.name);let fn1 = test;console.log(fn1.toString(), "-- name -- ", fn1.name);let fn2 = function(){ }console.log(fn2.toString(), "-- name -- ", fn2.name);console.log("\nFunction Expression")console.log("-------------------------")let fn3 = function f() { }console.log(fn3.toString(), "-- name -- ", fn3.name);console.log("\nObject function")console.log("-------------------------")let obj = { fobj() { } }console.log(obj.fobj.toString(), "-- name -- ", obj.fobj.name);console.log("\n with new Function constructor")console.log("-------------------------")let fn4 = (new Function); // "anonymous"console.log(fn4.toString(), "-- name -- ", fn4.name);console.log("\n Arrow function")console.log("-------------------------")let arrow = ( () => {} ).name;console.log("Arrow function name", arrow); // empty stringconsole.log("((){}).name => ", ( () => {} ).name); // empty stringconsole.log("\n Bind Function")console.log("-------------------------")function fn5() { };let bindFn = fn5.bind({});console.log(bindFn.toString(), "-- name -- ", bindFn.name);
```
Run
## Explanation
The following explanations can provide a better understanding of the code above.
### Function 1
The `test.name` will be `test`.
```
function test() {
}
```
### Explanation 1
We used the `test.toString` method to print the function as a string.
### Function 2
```
function test(){
}
let fn1 = test;
fn1.name; // test
```
### Explanation 2
We assigned the `test` function to an `fn1` variable and accessed the `name` property through the `fn1` variable like `fn1.name`. This will return `test` as the function name.
### Function 3
```
let fn2 = function(){
}
fn2.name;
```
### Explanation 3
We created an anonymous function and assigned it to a variable. Internally, the function name is inferred as the variable name. So, the `fn2.name` will hold `fn2` as its value.
### Function 4
```
let fn3 = function f(){
}
fn3.name;
```
### Explanation 4
We created a function expression with the function name `f` and assigned it to an `fn3` variable. Now, the `fn3.name` holds `f` as the value.
***
### Function 5
```
let obj = {
fobj(){
}
}
obj.fobj.name; // fobj
```
### Explanation 5
We created an object that has the `fobj` function. The `obj.fobj.name` will hold `fobj` as the function name.
### Function 6
```
let fn4 = (new Function);
fn4.name;
```
### Explanation 6
We created a function with `new Function`, which will internally generate a function called `anonymous`. The `fn4.name` will hold `anonymous` as a value.
### Function 7
```
let arrow = (()=>{}).name;
arrow; // ""
```
### Explanation 7
We created an `arrow function`. The `name` property of the arrow functions is an empty string.
Additionally, the name of the `anonymous` function is also an empty `string` if it is not assigned to a variable.
```
(function(){}).name; // ""
```
### Function 8
```
function fn5() {};
let bindFn = fn5.bind({});
```
### Explanation 8
We created an `fn5` function and bound it to an empty object. For the `bind` function, JavaScript will add the word `bound` before the function name.
In our case, the `bindFn.name` will have `bound fn5` as a value.
Relevant Answers
Explore Courses
Free Resources
License: [Creative Commons-Attribution-ShareAlike 4.0 (CC-BY-SA 4.0)](https://creativecommons.org/licenses/by-sa/4.0/) |
| Readable Markdown | ```
console.log("\Normal Function")console.log("-------------------------")function test(){ }console.log(test.toString(), "-- name -- ", test.name);let fn1 = test;console.log(fn1.toString(), "-- name -- ", fn1.name);let fn2 = function(){ }console.log(fn2.toString(), "-- name -- ", fn2.name);console.log("\nFunction Expression")console.log("-------------------------")let fn3 = function f() { }console.log(fn3.toString(), "-- name -- ", fn3.name);console.log("\nObject function")console.log("-------------------------")let obj = { fobj() { } }console.log(obj.fobj.toString(), "-- name -- ", obj.fobj.name);console.log("\n with new Function constructor")console.log("-------------------------")let fn4 = (new Function); // "anonymous"console.log(fn4.toString(), "-- name -- ", fn4.name);console.log("\n Arrow function")console.log("-------------------------")let arrow = ( () => {} ).name;console.log("Arrow function name", arrow); // empty stringconsole.log("((){}).name => ", ( () => {} ).name); // empty stringconsole.log("\n Bind Function")console.log("-------------------------")function fn5() { };let bindFn = fn5.bind({});console.log(bindFn.toString(), "-- name -- ", bindFn.name);
``` |
| ML Classification | |
| ML Categories | null |
| ML Page Types | null |
| ML Intent Types | null |
| Content Metadata | |
| Language | en |
| Author | null |
| Publish Time | not set |
| Original Publish Time | 2025-01-24 17:13:15 (1 year ago) |
| Republished | No |
| Word Count (Total) | 638 |
| Word Count (Content) | 133 |
| Links | |
| External Links | 2 |
| Internal Links | 7 |
| Technical SEO | |
| Meta Nofollow | No |
| Meta Noarchive | No |
| JS Rendered | No |
| Redirect Target | null |
| Performance | |
| Download Time (ms) | 179 |
| TTFB (ms) | 168 |
| Download Size (bytes) | 57,135 |
| Shard | 28 (laksa) |
| Root Hash | 12990463358539855228 |
| Unparsed URL | io,educative!www,/answers/what-is-functionname-in-javascript s443 |