Last active
November 28, 2018 00:39
-
-
Save harrisonmalone/21675dbcac6d834b127c887298f97d53 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
test() | |
// when we invoke this function it breaks | |
// the variable test (const test) is hoisted but not what's stored in it | |
// function expressions aren't hoisted | |
testTwo() | |
// whereas because testTwo is a function declaration it doesn't break when we invoke it above the actual declaration | |
// the whole function declaration is hoisted and we can use it anywhere in the global scope | |
// example of function expression | |
const test = function() { | |
console.log("hi") | |
} | |
const test = () => console.log("hi") | |
// example of function declaration | |
function testTwo() { | |
console.log("hello") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment