-
-
Save danielimmke/07ac10e272d1ff14ea0a1ce72e418fc4 to your computer and use it in GitHub Desktop.
Function Declaration vs Function Expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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