Function Declaration vs. Function Expression
by sikusikucom
JavaScript
// 'function declaration' is hoisted
// 'myAdd' is visible at this point even though it is declared
// only after this call.
myAdd(3, 2);
function myAdd(a, b) {
console.log(a + b);
}
// mySubstract is not recognized at this point.
// 'function expression'
var mySubtract = function (a, b) {
console.log(a - b);
}
mySubtract(3, 2);