Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function Declaration vs Function Expressions
hoistedFunction();
// This declaration is moved to the top before the JS is executed.
function hoistedFunction() {
console.log('Hoisted function. Bad!');
}
// If we tried to call this function before this expression, JS would throw an error!
const nonHoistedFunction = function() {
console.log('Not hoisted! Good!')
}
nonHoistedFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment