Skip to content

Instantly share code, notes, and snippets.

@danielimmke
Last active July 11, 2018 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielimmke/07ac10e272d1ff14ea0a1ce72e418fc4 to your computer and use it in GitHub Desktop.
Save danielimmke/07ac10e272d1ff14ea0a1ce72e418fc4 to your computer and use it in GitHub Desktop.
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