MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/onix79/javascript_function_facts/h5th1yw/?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'; }
8 u/senocular Jul 19 '21 All declarations are hoisted. Function declarations are the only declarations that also host their definition though. 7 u/HashFap Jul 20 '21 All declarations are parsed before the code is executed, but you won't be able to access the values stored in let and const until after the declaration line.
8
All declarations are hoisted. Function declarations are the only declarations that also host their definition though.
7 u/HashFap Jul 20 '21 All declarations are parsed before the code is executed, but you won't be able to access the values stored in let and const until after the declaration line.
7
All declarations are parsed before the code is executed, but you won't be able to access the values stored in let and const until after the declaration line.
let
const
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: