Languages
[Edit]
EN

JavaScript - create and use functions

7 points
Created by:
Elias999
819

In this article, we would like to show you how to create and use functions in JavaScript.

1. Function function / class example

Edit

Output (with NodeJS):

2. Anonymous function example

Edit

2.1. With function name from the variable name

Edit

Output (with NodeJS):

2.2. With own function name

Edit

Output (with NodeJS):

3. Arrow function example

Edit

Arrow function has been introduced in ES6. This part shows in a simple way how to use arrow functions.

3.1. With function body in brackets

Output (with NodeJS):

3.2. Without brackets - with auto-returning of values

Output (with NodeJS):

4. Calling function/method ways

Edit

The ways how to call function (method) has been described in this article.

See also

Edit
  1. JavaScript - different ways to call function

Alternative titles

  1. JavaScript - how to create and use functions?
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