Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Last active November 28, 2018 00:39
Show Gist options
  • Save harrisonmalone/21675dbcac6d834b127c887298f97d53 to your computer and use it in GitHub Desktop.
Save harrisonmalone/21675dbcac6d834b127c887298f97d53 to your computer and use it in GitHub Desktop.
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