Expression Function
- Function expression is stored in a variable
const multiply = function(a, b) {
return a * b;
};
the variable can be used as a function
function expression are used to create anonymous functions.
A expresion function can be assigned to a varaiable the passed a arrugument to another function and returned from function
In JavaScript, function declarations and function expression refer to different ways of defining functions, there are different in the syntax but both the works are same .
Hosting
function decleration can be called top of the function
function expression can be called after function decleration.
use function decleration in general - purpose function.
use function expression to assign a variable in another function and for callback .
*Arrow function *
- Arrow function are shorten of expression function
const add = (a, b) => {
return a + b;
};
arrow function uses the arrow symbole
This arrow function does the same thing as a regular function expression.
Arrow functions are not hoisted
Parentheses are required for zero or multiple parameters.
Top comments (0)