MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/onix79/javascript_function_facts/h5u4os9/?context=3
r/learnjavascript • u/hsnice • Jul 19 '21
27 comments sorted by
View all comments
20
function declarations aren't the only thing that is hoisted, variable declarations with var are also hoisted.
var
e.g. the following does not work:
console.log('hello', future()); const future = function() { return ' world'; }
1 u/hsnice Jul 20 '21 The following code does not work because it is a function expression, not a function declaration.
1
The following code does not work because it is a function expression, not a function declaration.
20
u/[deleted] Jul 19 '21
function declarations aren't the only thing that is hoisted, variable declarations with
varare also hoisted.e.g. the following does not work: