DEV Community

Praveen Kumar K
Praveen Kumar K

Posted on

Define Function in Javascript?

Step 1:

What are Functions?
Functions are reusable code blocks designed for particular tasks.
Functions are executed when they are called or invoked
Functions are fundamental in all programming languages.

Step 2:

Calling Functions:

Functions are executed when they are called or invoked
You call a function by adding parentheses to its name: name().

Step 3:

Function Parameters:

Parameters allow you to send values to a function.
Parameters are listed in parentheses in the function definition.

Step 4:

Function Return Values:

A function can return a value back to the code that called it.
The return statement is used to return a value from a function.

Step 5:

Function Arguments:

Function parameters and arguments are distinct concepts.
Parameters are the names listed in the function definition.
Arguments are the values received by the function.

Step 6:

Function Expressions:

A function expression is a function stored in a variable
The variable name can be used to call the function.

Step 7:

Arrow Functions:

Arrow Functions is a short syntax for function expressions.
You can skip the function keyword.
You can skip the return keyword.
You can skip the curly brackets.

For Example:

![ ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wg76mxv3uy34yoy80yvy.jpg

Simple Program and Output:

Top comments (0)