ℹ️ 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 months ago (distributed domain, exempt) |
| 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://github.com/airbnb/javascript/issues/794 |
| Last Crawled | 2026-04-12 20:12:44 (1 day ago) |
| First Indexed | 2016-03-27 16:30:56 (10 years ago) |
| HTTP Status Code | 200 |
| Meta Title | 7.1 says function expressions are always unnamed, but this changed in ES6 · Issue #794 · airbnb/javascript |
| Meta Description | 7.1 contains this statement: Function declarations are named, so they're easier to identify in call stacks. Anonymous function expressions assigned to a binding are also named, per ES6 semantics (1.e.iii). That is, the "bad" example cons... |
| Meta Canonical | null |
| Boilerpipe Text | ljharb commented
on Mar 21, 2016
ljharb
on Mar 21, 2016
Collaborator
Function name inference is implemented in hardly any of the browsers we support. In addition, relying on function name inference hinders greppability, so even in a pure ES6 environment, we wouldn't recommend that.
(other subtler differences are that a function with an inferred name still doesn't have a lexical name binding in the function body, but that's not relevant here)
ljharb
closed this as
completed
on Mar 21, 2016
Arnavion commented
on Mar 21, 2016
Arnavion
on Mar 21, 2016
Contributor
Author
Do you want to clarify that in the document itself? Via footnote, etc.
ljharb commented
on Mar 21, 2016
ljharb
on Mar 21, 2016
Collaborator
Sure, that's a great idea for a footnote!
ljharb
reopened this
on Mar 21, 2016
ljharb
added
pull request wanted
editorial
on Mar 21, 2016
beck
mentioned this
on May 31, 2016
Update README to include ES6 Practices
yola/jsgreat#21
hshoff
added a commit that references this issue
on Aug 26, 2016
[7.1] add link to fn names discussion.
fixes
#794
1541503
hshoff
mentioned this
on Aug 26, 2016
[7.1] add link to fn names discussion. fixes #794
#1036
ljharb
closed this as
completed
in
#1036
on Aug 26, 2016
ramasilveyra
added a commit that references this issue
on Dec 6, 2016
[7.1] add link to fn names discussion.
fixes
airbnb#794
f9d8629
hibearpanda
added a commit that references this issue
on Jan 22, 2017
[7.1] add link to fn names discussion.
fixes
airbnb#794
c72b418
tandav commented
on Feb 26, 2017
tandav
on Feb 26, 2017
... frome Style Guide:
// bad
const
foo
=
function
(
)
{
// ...
}
;
// good
const
foo
=
function
bar
(
)
{
// ...
}
;
So, you say, there should be 2 different names for one function?
For example,
// Is it worse
const
sum
=
function
(
a
,
b
)
{
return
a
+
b
;
}
;
// than this?
const
my_sum
=
function
sum
(
a
,
b
)
{
return
a
+
b
;
}
;
I'm a begginer in JS/ES, can you tell, please, what are advantages of second method?
ljharb commented
on Feb 26, 2017
ljharb
on Feb 26, 2017
Collaborator
@tandav
In your last example, the first function doesn't have a
.name
- which means in debugging, it's likely to show up as an anonymous function. In the latter example, it will show up with the name
sum
- and when you grep for it, all the uses in the file will use
my_sum
, so the actual function will be easier to locate.
46
remaining
items
LeoniePhiline commented
on Jan 23, 2021
LeoniePhiline
on Jan 23, 2021
@ljharb
You are so incredibly patient 👍
Jero786 commented
on Mar 11, 2022
Jero786
on Mar 11, 2022
@ljharb
I really agree with all the argument that
@Borthralla
put in the table. Please remember:
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton
Also I tested with Babel in my project (in the same way that mentioned
@JPeer264
) throwing Error, and the stack trace of the error are identical using arrow function vs named function statement.
At this point it should be just:
const foo = () => { ... }
babel just traspiler to:
var foo = function foo () { ... }
ljharb commented
on Mar 11, 2022
ljharb
on Mar 11, 2022
Collaborator
if Babel does that, then it may not be transpiling correctly, because non-arrow functions and arrow functions have actual runtime differences.
If you want a named function, use one.
rkrisztian
mentioned this
on Oct 17, 2022
Newspaper metaphor support
#2657
PavlovVitalii
mentioned this
on Oct 18, 2022
Feature/lesson 06
PavlovVitalii/Front-End-Pro#6
zhesha commented
on May 16, 2023
zhesha
on May 16, 2023
Contributor
Rule 7.1 states that I should use "named function expressions" and check it with "eslint:
func-style
" but eslint can check only that I use "function expression" or "function declaration". It did not check that the function expression is "named". Am I wrong? So the "eslint: func-style" is not applied to this rule. And there are no tools to check the whole codebase on this rule?
Also, the rule suggests not to use "function declarations", but the style guide violates it multiple times. Is it worth having a rule that can't be followed even in the style guide?
Rule 3.2
function getKey(k) {
return `a key named ${k}`;
}
Rule 5.1
// best
function getFullName({ firstName, lastName }) {
return `${firstName} ${lastName}`;
}
Rule 5.3
// good
function processInput(input) {
// then a miracle occurs
return { left, right, top, bottom };
}
Rule 6.3
// good
function sayHi(name) {
return `How are you, ${name}?`;
}
And more. In the style guide itself, there are tons of function expressions and function declarations and only 3 examples contain "named function expressions".
ljharb commented
on May 16, 2023
ljharb
on May 16, 2023
Collaborator
@zhesha
func-style
ensures that it's an expression, and
func-names
ensures it has a name.
Yes, a style guide must by necessity sometimes violate itself in order to show clear examples.
zhesha commented
on May 23, 2023
zhesha
on May 23, 2023
Contributor
@ljharb
Thank you for the clarification. But as rule 7.1 is checked by two eslint rules I think both of them should be in a style guide. I have created PR with this tiny change, do you think it's possible to apply it?
#2779
bubbavox commented
on Aug 11, 2023
bubbavox
on Aug 11, 2023
·
edited by
bubbavox
Like some others here, I'm challenged by this rule, but appreciate the reasoning behind it. If I'm calling the function by its variable, then I want that variable to be expressive, for readability.
const
foo
=
function
fooLex
(
)
How about that?
Excerpt from
MDN JS guide
:
"...Providing a name allows the function to refer to itself, and also makes it easier to identify the function in a debugger's stack traces:"
const
factorial
=
function
fac
(
n
)
{
return
n
<
2
?
1
:
n
*
fac
(
n
-
1
)
;
}
;
console
.
log
(
factorial
(
3
)
)
;
// 6
Interesting that the function's lexical name is the short name, while the variable is more descriptive.
ljharb commented
on Aug 11, 2023
ljharb
on Aug 11, 2023
Collaborator
@bubbavox
i agree with you that the internal name should be more descriptive than the outer variable, but pragmatism may prefer the other approach at times :-)
iamstoick
mentioned this
on Feb 2, 2024
[Snyk] Security upgrade babel-eslint from 3.1.7 to 10.1.0
iamstoick/javascript#8
noahblon
mentioned this
on Feb 2, 2024
[Snyk] Security upgrade babel-eslint from 7.2.2 to 10.1.0
noahblon/javascript-standards#23
iamstoick
mentioned this
on Apr 15, 2024
[Snyk] Fix for 1 vulnerabilities
iamstoick/javascript#9
wo-o29
mentioned this
on Oct 29, 2024
[자동차 경주] 문성희 미션 제출합니다.
woowacourse-precourse/javascript-racingcar-7#404
yoon-jeong-ho15
mentioned this
on Oct 27, 2025
[자동차 경주] 윤정호 미션 제출합니다.
woowacourse-precourse/javascript-racingcar-8#154 |
| Markdown | [Skip to content](https://github.com/airbnb/javascript/issues/794#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fairbnb%2Fjavascript%2Fissues%2F794)
Appearance settings
- Platform
- AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
- DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
- APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
- EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com/)
- [Blog](https://github.blog/)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
- Solutions
- BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
- BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
- BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
- Resources
- EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
- EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com/)
- SUPPORT & SERVICES
- [Documentation](https://docs.github.com/)
- [Customer support](https://support.github.com/)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
[View all resources](https://github.com/resources)
- Open Source
- COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
- PROGRAMS
- [Security Lab](https://securitylab.github.com/)
- [Maintainer Community](https://maintainers.github.com/)
- [Accelerator](https://github.com/accelerator)
- [GitHub Stars](https://stars.github.com/)
- [Archive Program](https://archiveprogram.github.com/)
- REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
- Enterprise
- ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
- AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
- [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Cancel
Create saved search
[Sign in](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fairbnb%2Fjavascript%2Fissues%2F794)
[Sign up](https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=airbnb%2Fjavascript)
Appearance settings
Resetting focus
You signed in with another tab or window. [Reload](https://github.com/airbnb/javascript/issues/794) to refresh your session. You signed out in another tab or window. [Reload](https://github.com/airbnb/javascript/issues/794) to refresh your session. You switched accounts on another tab or window. [Reload](https://github.com/airbnb/javascript/issues/794) to refresh your session.
Dismiss alert
[airbnb](https://github.com/airbnb) / **[javascript](https://github.com/airbnb/javascript)** Public
- [Notifications](https://github.com/login?return_to=%2Fairbnb%2Fjavascript)
You must be signed in to change notification settings
- [Fork 26.7k](https://github.com/login?return_to=%2Fairbnb%2Fjavascript)
- [Star 148k](https://github.com/login?return_to=%2Fairbnb%2Fjavascript)
- [Code](https://github.com/airbnb/javascript)
- [Issues 102](https://github.com/airbnb/javascript/issues)
- [Pull requests 88](https://github.com/airbnb/javascript/pulls)
- [Actions](https://github.com/airbnb/javascript/actions)
- [Wiki](https://github.com/airbnb/javascript/wiki)
- [Security and quality 0](https://github.com/airbnb/javascript/security)
- [Insights](https://github.com/airbnb/javascript/pulse)
Additional navigation options
- [Code](https://github.com/airbnb/javascript)
- [Issues](https://github.com/airbnb/javascript/issues)
- [Pull requests](https://github.com/airbnb/javascript/pulls)
- [Actions](https://github.com/airbnb/javascript/actions)
- [Wiki](https://github.com/airbnb/javascript/wiki)
- [Security and quality](https://github.com/airbnb/javascript/security)
- [Insights](https://github.com/airbnb/javascript/pulse)
# 7\.1 says function expressions are always unnamed, but this changed in ES6 \#794
[New issue](https://github.com/login?return_to=https://github.com/airbnb/javascript/issues/794)
Copy link
[New issue](https://github.com/login?return_to=https://github.com/airbnb/javascript/issues/794)
Copy link
Closed
[\#1036](https://github.com/airbnb/javascript/pull/1036)
Closed
[7\.1 says function expressions are always unnamed, but this changed in ES6](https://github.com/airbnb/javascript/issues/794#top)
\#794
[\#1036](https://github.com/airbnb/javascript/pull/1036)
Copy link
Labels
[editorial](https://github.com/airbnb/javascript/issues?q=state%3Aopen%20label%3A%22editorial%22)[pull request wanted](https://github.com/airbnb/javascript/issues?q=state%3Aopen%20label%3A%22pull%20request%20wanted%22)
[](https://github.com/Arnavion)
## Description
[](https://github.com/Arnavion)
[Arnavion](https://github.com/Arnavion)
opened
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#issue-142266110)
Contributor
Issue body actions
[7\.1](https://github.com/airbnb/javascript#functions--declarations) contains this statement:
> Function declarations are named, so they're easier to identify in call stacks.
Anonymous function expressions assigned to a binding are *also* named, per [ES6 semantics (1.e.iii).](http://www.ecma-international.org/ecma-262/6.0/#sec-assignment-operators-runtime-semantics-evaluation) That is, the "bad" example `const foo = function () { };` is the same as `const foo = function foo() { };`, which is equivalent to the "good" example `function foo() { }` in that respect.
Should the statement be qualified that it's only a distinction for ES5 and below ?
😕React with 😕1
ViktorKuzeminskyi
## Activity
[Next](https://github.com/airbnb/javascript/issues/794?timeline_page=1)
[](https://github.com/ljharb)
### ljharb commented on Mar 21, 2016
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#issuecomment-199142117)
Collaborator
More actions
Function name inference is implemented in hardly any of the browsers we support. In addition, relying on function name inference hinders greppability, so even in a pure ES6 environment, we wouldn't recommend that.
(other subtler differences are that a function with an inferred name still doesn't have a lexical name binding in the function body, but that's not relevant here)
[ljharb](https://github.com/ljharb)
closed this as [completed](https://github.com/airbnb/javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#event-596700751)
[](https://github.com/Arnavion)
### Arnavion commented on Mar 21, 2016
[](https://github.com/Arnavion)
[Arnavion](https://github.com/Arnavion)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#issuecomment-199142584)
ContributorAuthor
More actions
Do you want to clarify that in the document itself? Via footnote, etc.
[](https://github.com/ljharb)
### ljharb commented on Mar 21, 2016
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#issuecomment-199142857)
Collaborator
More actions
Sure, that's a great idea for a footnote\!
[ljharb](https://github.com/ljharb)
reopened this
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#event-596702074)
[ljharb](https://github.com/ljharb)
added
[pull request wanted](https://github.com/airbnb/javascript/issues?q=state%3Aopen%20label%3A%22pull%20request%20wanted%22)
[editorial](https://github.com/airbnb/javascript/issues?q=state%3Aopen%20label%3A%22editorial%22)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#event-596702119)
[beck](https://github.com/beck)
mentioned this
[on May 31, 2016](https://github.com/airbnb/javascript/issues/794#event-159415829)
- [Update README to include ES6 Practices yola/jsgreat\#21](https://github.com/yola/jsgreat/issues/21)
[hshoff](https://github.com/hshoff)
added a commit that references this issue
[on Aug 26, 2016](https://github.com/airbnb/javascript/issues/794#event-768426751)
[\[7.1\] add link to fn names discussion. fixes](https://github.com/airbnb/javascript/commit/1541503fd47626e2d4b03ff01bca76940081edeb) [\#794](https://github.com/airbnb/javascript/issues/794)
This issue will close once commit 1541503 is merged into the 'master' branch.[1541503](https://github.com/airbnb/javascript/commit/1541503fd47626e2d4b03ff01bca76940081edeb)
[hshoff](https://github.com/hshoff)
mentioned this
[on Aug 26, 2016](https://github.com/airbnb/javascript/issues/794#event-202997025)
- [\[7.1\] add link to fn names discussion. fixes \#794 \#1036](https://github.com/airbnb/javascript/pull/1036)
[ljharb](https://github.com/ljharb)
closed this as [completed](https://github.com/airbnb/javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted)in [\#1036](https://github.com/airbnb/javascript/pull/1036)
[on Aug 26, 2016](https://github.com/airbnb/javascript/issues/794#event-768493004)
[ramasilveyra](https://github.com/ramasilveyra)
added a commit that references this issue
[on Dec 6, 2016](https://github.com/airbnb/javascript/issues/794#event-884086836)
[\[7.1\] add link to fn names discussion. fixes](https://github.com/auth0/javascript/commit/f9d86292c4c4df8a8812016f9fb19be193870e3b) [airbnb\#794](https://github.com/airbnb/javascript/issues/794)
This issue will close once commit f9d8629 is merged into the 'master' branch.[f9d8629](https://github.com/auth0/javascript/commit/f9d86292c4c4df8a8812016f9fb19be193870e3b)
[hibearpanda](https://github.com/hibearpanda)
added a commit that references this issue
[on Jan 22, 2017](https://github.com/airbnb/javascript/issues/794#event-931985360)
[\[7.1\] add link to fn names discussion. fixes](https://github.com/15Prospects/javascript/commit/c72b4183e89cc2d2a7d49336e98f3752500d20f2) [airbnb\#794](https://github.com/airbnb/javascript/issues/794)
This issue will close once commit c72b418 is merged into the 'master' branch.[c72b418](https://github.com/15Prospects/javascript/commit/c72b4183e89cc2d2a7d49336e98f3752500d20f2)
[](https://github.com/tandav)
### tandav commented on Feb 26, 2017
[](https://github.com/tandav)
[tandav](https://github.com/tandav)
[on Feb 26, 2017](https://github.com/airbnb/javascript/issues/794#issuecomment-282556355)
More actions
... frome Style Guide:
```
// bad
const foo = function () {
// ...
};
// good
const foo = function bar() {
// ...
};
```
So, you say, there should be 2 different names for one function?
For example,
```
// Is it worse
const sum = function(a, b) {
return a + b;
};
// than this?
const my_sum = function sum(a, b) {
return a + b;
};
```
I'm a begginer in JS/ES, can you tell, please, what are advantages of second method?
👍React with 👍30
riyadshauk, michaelhood, dijonkitchen, jonleopard, ViktorKuzeminskyi and 25 more
👀React with 👀3
DVegasa, yunimm and pjlunardelli
[](https://github.com/ljharb)
### ljharb commented on Feb 26, 2017
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Feb 26, 2017](https://github.com/airbnb/javascript/issues/794#issuecomment-282574765)
Collaborator
More actions
[@tandav](https://github.com/tandav) In your last example, the first function doesn't have a `.name` - which means in debugging, it's likely to show up as an anonymous function. In the latter example, it will show up with the name `sum` - and when you grep for it, all the uses in the file will use `my_sum`, so the actual function will be easier to locate.
👍React with 👍38
tuanluu-agilityio, phthhieu, GoodGuyGroves, ayoisaiah, 1MoreBuild and 33 more
### 46 remaining items
Load more
[](https://github.com/LeoniePhiline)
### LeoniePhiline commented on Jan 23, 2021
[](https://github.com/LeoniePhiline)
[LeoniePhiline](https://github.com/LeoniePhiline)
[on Jan 23, 2021](https://github.com/airbnb/javascript/issues/794#issuecomment-766196399)
More actions
[@ljharb](https://github.com/ljharb) You are so incredibly patient 👍
😄React with 😄1
stieben
❤️React with ❤️3
ljharb, sbedell and wachukxs
[](https://github.com/Jero786)
### Jero786 commented on Mar 11, 2022
[](https://github.com/Jero786)
[Jero786](https://github.com/Jero786)
[on Mar 11, 2022](https://github.com/airbnb/javascript/issues/794#issuecomment-1064908378)
More actions
[@ljharb](https://github.com/ljharb) I really agree with all the argument that [@Borthralla](https://github.com/Borthralla) put in the table. Please remember:
> There are only two hard things in Computer Science: cache invalidation and naming things.
> -- Phil Karlton
Also I tested with Babel in my project (in the same way that mentioned [@JPeer264](https://github.com/JPeer264)) throwing Error, and the stack trace of the error are identical using arrow function vs named function statement.
At this point it should be just:
```
const foo = () => { ... }
```
babel just traspiler to:
```
var foo = function foo () { ... }
```
[](https://github.com/ljharb)
### ljharb commented on Mar 11, 2022
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Mar 11, 2022](https://github.com/airbnb/javascript/issues/794#issuecomment-1065177776)
Collaborator
More actions
if Babel does that, then it may not be transpiling correctly, because non-arrow functions and arrow functions have actual runtime differences.
If you want a named function, use one.
[rkrisztian](https://github.com/rkrisztian)
mentioned this
[on Oct 17, 2022](https://github.com/airbnb/javascript/issues/794#event-1222243282)
- [Newspaper metaphor support \#2657](https://github.com/airbnb/javascript/issues/2657)
[PavlovVitalii](https://github.com/PavlovVitalii)
mentioned this
[on Oct 18, 2022](https://github.com/airbnb/javascript/issues/794#event-1222499186)
- [Feature/lesson 06 PavlovVitalii/Front-End-Pro\#6](https://github.com/PavlovVitalii/Front-End-Pro/pull/6)
[](https://github.com/zhesha)
### zhesha commented on May 16, 2023
[](https://github.com/zhesha)
[zhesha](https://github.com/zhesha)
[on May 16, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1549585263)
Contributor
More actions
Rule 7.1 states that I should use "named function expressions" and check it with "eslint: [func-style](https://eslint.org/docs/rules/func-style)" but eslint can check only that I use "function expression" or "function declaration". It did not check that the function expression is "named". Am I wrong? So the "eslint: func-style" is not applied to this rule. And there are no tools to check the whole codebase on this rule?
Also, the rule suggests not to use "function declarations", but the style guide violates it multiple times. Is it worth having a rule that can't be followed even in the style guide?
Rule 3.2
```
function getKey(k) {
return `a key named ${k}`;
}
```
Rule 5.1
```
// best
function getFullName({ firstName, lastName }) {
return `${firstName} ${lastName}`;
}
```
Rule 5.3
```
// good
function processInput(input) {
// then a miracle occurs
return { left, right, top, bottom };
}
```
Rule 6.3
```
// good
function sayHi(name) {
return `How are you, ${name}?`;
}
```
And more. In the style guide itself, there are tons of function expressions and function declarations and only 3 examples contain "named function expressions".
👍React with 👍1
rob3c
[](https://github.com/ljharb)
### ljharb commented on May 16, 2023
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on May 16, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1550067074)
Collaborator
More actions
[@zhesha](https://github.com/zhesha) `func-style` ensures that it's an expression, and `func-names` ensures it has a name.
Yes, a style guide must by necessity sometimes violate itself in order to show clear examples.
[](https://github.com/zhesha)
### zhesha commented on May 23, 2023
[](https://github.com/zhesha)
[zhesha](https://github.com/zhesha)
[on May 23, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1559184360)
Contributor
More actions
[@ljharb](https://github.com/ljharb) Thank you for the clarification. But as rule 7.1 is checked by two eslint rules I think both of them should be in a style guide. I have created PR with this tiny change, do you think it's possible to apply it? [\#2779](https://github.com/airbnb/javascript/pull/2779)
👀React with 👀1
ljharb
[](https://github.com/bubbavox)
### bubbavox commented on Aug 11, 2023
[](https://github.com/bubbavox)
[bubbavox](https://github.com/bubbavox)
[on Aug 11, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1675470198)
· edited by [bubbavox](https://github.com/bubbavox)
Edits
More actions
Like some others here, I'm challenged by this rule, but appreciate the reasoning behind it. If I'm calling the function by its variable, then I want that variable to be expressive, for readability.
```
const foo = function fooLex()
```
How about that?
Excerpt from [MDN JS guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions):
"...Providing a name allows the function to refer to itself, and also makes it easier to identify the function in a debugger's stack traces:"
```
const factorial = function fac(n) {
return n < 2 ? 1 : n * fac(n - 1);
};
console.log(factorial(3)); // 6
```
Interesting that the function's lexical name is the short name, while the variable is more descriptive.
[](https://github.com/ljharb)
### ljharb commented on Aug 11, 2023
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Aug 11, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1675478144)
Collaborator
More actions
[@bubbavox](https://github.com/bubbavox) i agree with you that the internal name should be more descriptive than the outer variable, but pragmatism may prefer the other approach at times :-)
👍React with 👍2
wrobson-lllow and biplobsec21
[iamstoick](https://github.com/iamstoick)
mentioned this
[on Feb 2, 2024](https://github.com/airbnb/javascript/issues/794#event-1353020547)
- [\[Snyk\] Security upgrade babel-eslint from 3.1.7 to 10.1.0 iamstoick/javascript\#8](https://github.com/iamstoick/javascript/pull/8)
[noahblon](https://github.com/noahblon)
mentioned this
[on Feb 2, 2024](https://github.com/airbnb/javascript/issues/794#event-1353066804)
- [\[Snyk\] Security upgrade babel-eslint from 7.2.2 to 10.1.0 noahblon/javascript-standards\#23](https://github.com/noahblon/javascript-standards/pull/23)
[iamstoick](https://github.com/iamstoick)
mentioned this
[on Apr 15, 2024](https://github.com/airbnb/javascript/issues/794#event-1378596513)
- [\[Snyk\] Fix for 1 vulnerabilities iamstoick/javascript\#9](https://github.com/iamstoick/javascript/pull/9)
[wo-o29](https://github.com/wo-o29)
mentioned this
[on Oct 29, 2024](https://github.com/airbnb/javascript/issues/794#event-1626799988)
- [\[자동차 경주\] 문성희 미션 제출합니다. woowacourse-precourse/javascript-racingcar-7\#404](https://github.com/woowacourse-precourse/javascript-racingcar-7/pull/404)
[yoon-jeong-ho15](https://github.com/yoon-jeong-ho15)
mentioned this
[on Oct 27, 2025](https://github.com/airbnb/javascript/issues/794#event-3732129176)
- [\[자동차 경주\] 윤정호 미션 제출합니다. woowacourse-precourse/javascript-racingcar-8\#154](https://github.com/woowacourse-precourse/javascript-racingcar-8/pull/154)
[Sign up for free](https://github.com/signup?return_to=https://github.com/airbnb/javascript/issues/794) **to join this conversation on GitHub.** Already have an account? [Sign in to comment](https://github.com/login?return_to=https://github.com/airbnb/javascript/issues/794)
## Metadata
## Metadata
### Assignees
No one assigned
### Labels
[editorial](https://github.com/airbnb/javascript/issues?q=state%3Aopen%20label%3A%22editorial%22)[pull request wanted](https://github.com/airbnb/javascript/issues?q=state%3Aopen%20label%3A%22pull%20request%20wanted%22)
### Type
No type
### Projects
No projects
### Milestone
No milestone
### Relationships
None yet
### Development
Code with agent mode
Select code repository
- [\[7.1\] add link to fn names discussion. fixes \#794airbnb/javascript](https://github.com/airbnb/javascript/pull/1036)
### Participants
[](https://github.com/ljharb)[](https://github.com/chengyin)[](https://github.com/teohhanhui)[](https://github.com/CinchBlue)[](https://github.com/Arnavion)
\+17
## Issue actions
## Footer
© 2026 GitHub, Inc.
### Footer navigation
- [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
- [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
- [Security](https://github.com/security)
- [Status](https://www.githubstatus.com/)
- [Community](https://github.community/)
- [Docs](https://docs.github.com/)
- [Contact](https://support.github.com/?tags=dotcom-footer)
- Manage cookies
- Do not share my personal information
You can’t perform that action at this time. |
| Readable Markdown | [](https://github.com/ljharb)
### ljharb commented on Mar 21, 2016
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#issuecomment-199142117)
Collaborator
Function name inference is implemented in hardly any of the browsers we support. In addition, relying on function name inference hinders greppability, so even in a pure ES6 environment, we wouldn't recommend that.
(other subtler differences are that a function with an inferred name still doesn't have a lexical name binding in the function body, but that's not relevant here)
[ljharb](https://github.com/ljharb)
closed this as [completed](https://github.com/airbnb/javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#event-596700751)
[](https://github.com/Arnavion)
### Arnavion commented on Mar 21, 2016
[](https://github.com/Arnavion)
[Arnavion](https://github.com/Arnavion)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#issuecomment-199142584)
ContributorAuthor
Do you want to clarify that in the document itself? Via footnote, etc.
[](https://github.com/ljharb)
### ljharb commented on Mar 21, 2016
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#issuecomment-199142857)
Collaborator
Sure, that's a great idea for a footnote\!
[ljharb](https://github.com/ljharb)
reopened this
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#event-596702074)
[ljharb](https://github.com/ljharb)
added
[pull request wanted](https://github.com/airbnb/javascript/issues?q=state%3Aopen%20label%3A%22pull%20request%20wanted%22)
[editorial](https://github.com/airbnb/javascript/issues?q=state%3Aopen%20label%3A%22editorial%22)
[on Mar 21, 2016](https://github.com/airbnb/javascript/issues/794#event-596702119)
[beck](https://github.com/beck)
mentioned this
[on May 31, 2016](https://github.com/airbnb/javascript/issues/794#event-159415829)
- [Update README to include ES6 Practices yola/jsgreat\#21](https://github.com/yola/jsgreat/issues/21)
[hshoff](https://github.com/hshoff)
added a commit that references this issue
[on Aug 26, 2016](https://github.com/airbnb/javascript/issues/794#event-768426751)
[\[7.1\] add link to fn names discussion. fixes](https://github.com/airbnb/javascript/commit/1541503fd47626e2d4b03ff01bca76940081edeb) [\#794](https://github.com/airbnb/javascript/issues/794)
[1541503](https://github.com/airbnb/javascript/commit/1541503fd47626e2d4b03ff01bca76940081edeb)
[hshoff](https://github.com/hshoff)
mentioned this
[on Aug 26, 2016](https://github.com/airbnb/javascript/issues/794#event-202997025)
- [\[7.1\] add link to fn names discussion. fixes \#794 \#1036](https://github.com/airbnb/javascript/pull/1036)
[ljharb](https://github.com/ljharb)
closed this as [completed](https://github.com/airbnb/javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted)in [\#1036](https://github.com/airbnb/javascript/pull/1036)
[on Aug 26, 2016](https://github.com/airbnb/javascript/issues/794#event-768493004)
[ramasilveyra](https://github.com/ramasilveyra)
added a commit that references this issue
[on Dec 6, 2016](https://github.com/airbnb/javascript/issues/794#event-884086836)
[\[7.1\] add link to fn names discussion. fixes](https://github.com/auth0/javascript/commit/f9d86292c4c4df8a8812016f9fb19be193870e3b) [airbnb\#794](https://github.com/airbnb/javascript/issues/794)
[f9d8629](https://github.com/auth0/javascript/commit/f9d86292c4c4df8a8812016f9fb19be193870e3b)
[hibearpanda](https://github.com/hibearpanda)
added a commit that references this issue
[on Jan 22, 2017](https://github.com/airbnb/javascript/issues/794#event-931985360)
[\[7.1\] add link to fn names discussion. fixes](https://github.com/15Prospects/javascript/commit/c72b4183e89cc2d2a7d49336e98f3752500d20f2) [airbnb\#794](https://github.com/airbnb/javascript/issues/794)
[c72b418](https://github.com/15Prospects/javascript/commit/c72b4183e89cc2d2a7d49336e98f3752500d20f2)
[](https://github.com/tandav)
### tandav commented on Feb 26, 2017
[](https://github.com/tandav)
[tandav](https://github.com/tandav)
[on Feb 26, 2017](https://github.com/airbnb/javascript/issues/794#issuecomment-282556355)
... frome Style Guide:
```
// bad
const foo = function () {
// ...
};
// good
const foo = function bar() {
// ...
};
```
So, you say, there should be 2 different names for one function?
For example,
```
// Is it worse
const sum = function(a, b) {
return a + b;
};
// than this?
const my_sum = function sum(a, b) {
return a + b;
};
```
I'm a begginer in JS/ES, can you tell, please, what are advantages of second method?
[](https://github.com/ljharb)
### ljharb commented on Feb 26, 2017
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Feb 26, 2017](https://github.com/airbnb/javascript/issues/794#issuecomment-282574765)
Collaborator
[@tandav](https://github.com/tandav) In your last example, the first function doesn't have a `.name` - which means in debugging, it's likely to show up as an anonymous function. In the latter example, it will show up with the name `sum` - and when you grep for it, all the uses in the file will use `my_sum`, so the actual function will be easier to locate.
46 remaining items
[](https://github.com/LeoniePhiline)
### LeoniePhiline commented on Jan 23, 2021
[](https://github.com/LeoniePhiline)
[LeoniePhiline](https://github.com/LeoniePhiline)
[on Jan 23, 2021](https://github.com/airbnb/javascript/issues/794#issuecomment-766196399)
[@ljharb](https://github.com/ljharb) You are so incredibly patient 👍
[](https://github.com/Jero786)
### Jero786 commented on Mar 11, 2022
[](https://github.com/Jero786)
[Jero786](https://github.com/Jero786)
[on Mar 11, 2022](https://github.com/airbnb/javascript/issues/794#issuecomment-1064908378)
[@ljharb](https://github.com/ljharb) I really agree with all the argument that [@Borthralla](https://github.com/Borthralla) put in the table. Please remember:
> There are only two hard things in Computer Science: cache invalidation and naming things.
> -- Phil Karlton
Also I tested with Babel in my project (in the same way that mentioned [@JPeer264](https://github.com/JPeer264)) throwing Error, and the stack trace of the error are identical using arrow function vs named function statement.
At this point it should be just:
```
const foo = () => { ... }
```
babel just traspiler to:
```
var foo = function foo () { ... }
```
[](https://github.com/ljharb)
### ljharb commented on Mar 11, 2022
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Mar 11, 2022](https://github.com/airbnb/javascript/issues/794#issuecomment-1065177776)
Collaborator
if Babel does that, then it may not be transpiling correctly, because non-arrow functions and arrow functions have actual runtime differences.
If you want a named function, use one.
[rkrisztian](https://github.com/rkrisztian)
mentioned this
[on Oct 17, 2022](https://github.com/airbnb/javascript/issues/794#event-1222243282)
- [Newspaper metaphor support \#2657](https://github.com/airbnb/javascript/issues/2657)
[PavlovVitalii](https://github.com/PavlovVitalii)
mentioned this
[on Oct 18, 2022](https://github.com/airbnb/javascript/issues/794#event-1222499186)
- [Feature/lesson 06 PavlovVitalii/Front-End-Pro\#6](https://github.com/PavlovVitalii/Front-End-Pro/pull/6)
[](https://github.com/zhesha)
### zhesha commented on May 16, 2023
[](https://github.com/zhesha)
[zhesha](https://github.com/zhesha)
[on May 16, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1549585263)
Contributor
Rule 7.1 states that I should use "named function expressions" and check it with "eslint: [func-style](https://eslint.org/docs/rules/func-style)" but eslint can check only that I use "function expression" or "function declaration". It did not check that the function expression is "named". Am I wrong? So the "eslint: func-style" is not applied to this rule. And there are no tools to check the whole codebase on this rule?
Also, the rule suggests not to use "function declarations", but the style guide violates it multiple times. Is it worth having a rule that can't be followed even in the style guide?
Rule 3.2
```
function getKey(k) {
return `a key named ${k}`;
}
```
Rule 5.1
```
// best
function getFullName({ firstName, lastName }) {
return `${firstName} ${lastName}`;
}
```
Rule 5.3
```
// good
function processInput(input) {
// then a miracle occurs
return { left, right, top, bottom };
}
```
Rule 6.3
```
// good
function sayHi(name) {
return `How are you, ${name}?`;
}
```
And more. In the style guide itself, there are tons of function expressions and function declarations and only 3 examples contain "named function expressions".
[](https://github.com/ljharb)
### ljharb commented on May 16, 2023
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on May 16, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1550067074)
Collaborator
[@zhesha](https://github.com/zhesha) `func-style` ensures that it's an expression, and `func-names` ensures it has a name.
Yes, a style guide must by necessity sometimes violate itself in order to show clear examples.
[](https://github.com/zhesha)
### zhesha commented on May 23, 2023
[](https://github.com/zhesha)
[zhesha](https://github.com/zhesha)
[on May 23, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1559184360)
Contributor
[@ljharb](https://github.com/ljharb) Thank you for the clarification. But as rule 7.1 is checked by two eslint rules I think both of them should be in a style guide. I have created PR with this tiny change, do you think it's possible to apply it? [\#2779](https://github.com/airbnb/javascript/pull/2779)
[](https://github.com/bubbavox)
### bubbavox commented on Aug 11, 2023
[](https://github.com/bubbavox)
[bubbavox](https://github.com/bubbavox)
[on Aug 11, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1675470198) · edited by [bubbavox](https://github.com/bubbavox)
Like some others here, I'm challenged by this rule, but appreciate the reasoning behind it. If I'm calling the function by its variable, then I want that variable to be expressive, for readability.
```
const foo = function fooLex()
```
How about that?
Excerpt from [MDN JS guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions):
"...Providing a name allows the function to refer to itself, and also makes it easier to identify the function in a debugger's stack traces:"
```
const factorial = function fac(n) {
return n < 2 ? 1 : n * fac(n - 1);
};
console.log(factorial(3)); // 6
```
Interesting that the function's lexical name is the short name, while the variable is more descriptive.
[](https://github.com/ljharb)
### ljharb commented on Aug 11, 2023
[](https://github.com/ljharb)
[ljharb](https://github.com/ljharb)
[on Aug 11, 2023](https://github.com/airbnb/javascript/issues/794#issuecomment-1675478144)
Collaborator
[@bubbavox](https://github.com/bubbavox) i agree with you that the internal name should be more descriptive than the outer variable, but pragmatism may prefer the other approach at times :-)
[iamstoick](https://github.com/iamstoick)
mentioned this
[on Feb 2, 2024](https://github.com/airbnb/javascript/issues/794#event-1353020547)
- [\[Snyk\] Security upgrade babel-eslint from 3.1.7 to 10.1.0 iamstoick/javascript\#8](https://github.com/iamstoick/javascript/pull/8)
[noahblon](https://github.com/noahblon)
mentioned this
[on Feb 2, 2024](https://github.com/airbnb/javascript/issues/794#event-1353066804)
- [\[Snyk\] Security upgrade babel-eslint from 7.2.2 to 10.1.0 noahblon/javascript-standards\#23](https://github.com/noahblon/javascript-standards/pull/23)
[iamstoick](https://github.com/iamstoick)
mentioned this
[on Apr 15, 2024](https://github.com/airbnb/javascript/issues/794#event-1378596513)
- [\[Snyk\] Fix for 1 vulnerabilities iamstoick/javascript\#9](https://github.com/iamstoick/javascript/pull/9)
[wo-o29](https://github.com/wo-o29)
mentioned this
[on Oct 29, 2024](https://github.com/airbnb/javascript/issues/794#event-1626799988)
- [\[자동차 경주\] 문성희 미션 제출합니다. woowacourse-precourse/javascript-racingcar-7\#404](https://github.com/woowacourse-precourse/javascript-racingcar-7/pull/404)
[yoon-jeong-ho15](https://github.com/yoon-jeong-ho15)
mentioned this
[on Oct 27, 2025](https://github.com/airbnb/javascript/issues/794#event-3732129176)
- [\[자동차 경주\] 윤정호 미션 제출합니다. woowacourse-precourse/javascript-racingcar-8\#154](https://github.com/woowacourse-precourse/javascript-racingcar-8/pull/154) |
| Shard | 174 (laksa) |
| Root Hash | 6325672905007345774 |
| Unparsed URL | com,github!/airbnb/javascript/issues/794 s443 |