Functions
1. Function is an object.
2. Function is a block of instruction used to perform a specific task.
3. A function gets executed only when it is called.
4. The main advantage of a function is that we can achieve code reusability.
5. To call a function, we need its reference and ().
6. The name of the function is a variable that holds the reference of the function object.
7. Creating a function using the function keyword supports function hoisting.
8. Therefore, we can also call a function before its declaration.
9. When we try to log the function name, the entire function definition is printed.
10. The scope within a function block is known as local scope.
11. Any member with local scope cannot be used outside the function block.
12. A parameter of a function will have local scope.
13. Variables written inside a function, even using var, have local scope.
14. Inside a function, we can use the members of the global scope.
15. In JavaScript, this is a property of every function (every function will have the this keyword except arrow functions).
Parameter
1. The variables declared in the function definition are known as parameters.
2. Parameters have local scope (can be used only inside the function body).
3. Parameters are used to hold the values passed by the caller (or calling statement).
Arguments
1. The values passed in the method call statement are known as arguments.
2. Note: An argument can be a literal, variable, or an expression that gives a result.
Return Keyword
1. It is a keyword used as a control transfer statement in a function.
2. Return will stop the execution of the function and transfer control along with data to the caller.
Ways to Create Functions
1. Function Declaration Statement: Create using function keyword
Functional Programming
1. Functional Programming is a programming technique where we pass a function along with a value to another function.
2. In this approach, we generate Generic Functions. Here, the function's task is not predefined. It performs multiple tasks, not just a single task.
3. The function that accepts another function as a parameter or returns a function is known as a Higher Order Function.
4. The function that is passed to another function or the function that is returned by another function is known as a Callback Function.