Function Declaration
- A function declaration also known as a function statement declares a function with a function keyword. The function declaration must have a function name.
- Function declaration does not require a variable assignment as they are standalone constructs and they cannot be nested inside a functional block.
- These are executed before any other code.
- The function in the function declaration can be accessed before and after the function definition.
function functionName()
{
// set of statements
}
Function Expression
- A function Expression is similar to a function declaration without the function name.
- Function expressions can be stored in a variable assignment.
- Function expressions load and execute only when the program interpreter reaches the line of code.
- The function in the function expression can be accessed only after the function definition.
let variableName = function (param1,param2)
{
// set of statements
}
console.log(variableName(args1,args2));
Reference Link
https://www.geeksforgeeks.org/javascript/difference-between-function-declaration-and-function-expression-in-javascript/
Top comments (0)