Languages
[Edit]
EN

JavaScript - when to put semicolon after function definition

3 points
Created by:
Gaia-Kirby
720

In this article, we would like to show you when to put a semicolon after a function in JavaScript.

Rule:

Semicolons are used to separate statements.

 

Hints:

Edit

1. Semicolons aren't necessary after function declarations (since they are not statements).

 

2. It is recommended to use semicolons after:

a) function expressions, because not using them may lead to bugs.

Old JSES6+

b) functions created with new operator, because not using them may lead to bugs.

 

References

Edit
  1. Semicolon - Wikipedia

Alternative titles

  1. JavaScript - when we should put semicolon after function definition?
  2. JavaScript - when to put semicolon after function declaration
  3. JavaScript - when to put semicolon after function statement
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join