A Function is much the same as a Procedure or a Subroutine, in other programming languages.
You can reuse code: Define the code once, and use it many times.
You can use the same code many times with different arguments, to produce different results.
- Function Declaration (function statement)
- Function Expression
- Function Constructor
- Self-Invoking Function (Immediately Invokable Function Expression IIFE)
- Arrow Function
- Object Method Shorthand Definition
- Generator Function
Function parameters are listed inside the parentheses () in the function definition.
Function arguments are the values received by the function when it is invoked.
Inside the function, the arguments (the parameters) behave as local variables.
1. Function Declaration (function statement)
When a function declaration is created, a variable named as function name is created as well. This variable is hoisted top of the current scope. In other words, variable is moved to top of current scope. This means that the function can be called before the function declarationContinue reading