What is the difference between a function declaration and function expression?
id:44Function declaration is when a function is given a name.(FD are hoisted, so can be invoked before the declaration) Function expressions do not have a name and do not get hoisted. Function expressions are invoked and forgotten immediately, therefore they avoid polluting the global scope.
(Rule) The function declaration in a statement always starts with the keyword “function”, otherwise it is a function expression.
function addUp(value1) // Function declaration
const addUp = function(value1) // Function expression
Function expressions can be declared to a variable and therefore they will have a .name property.