Because of how hoisting works, using a function expression will return undefined if you try to reference it before it is assigned and error if you try to call it before it is assigned.
Because function declarations are loaded before any code is executed, calling or referencing one will not return undefined or an error.
Bad Example
console.log(someFunc) // undefined
someFunc(); // TypeError - someFunc is not a function
function someFunc() {
console.log("some text");
}
Good Example
someFunc(); // some text
var someFunc = function() {
console.log("some text");
}
Because of how hoisting works, using a function expression will return undefined if you try to reference it before it is assigned and error if you try to call it before it is assigned.
Because function declarations are loaded before any code is executed, calling or referencing one will not return undefined or an error.
Bad Example
Good Example