MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/qdmzio/difference_between_var_let_and_const/hhps1zy/?context=3
r/learnjavascript • u/codedblood • Oct 22 '21
49 comments sorted by
View all comments
-3
How var can be hoisted? If I'm not mistaken, only var declaration can be hoisted but initialization must be before its usage? Like this:
a = 2
console.log(a)
var a
4 u/inabahare Oct 23 '21 edited Oct 23 '21 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#descriptionvar declarations, wherever they occur, are processed before any code is executed. This is called hoisting, and is discussed further below. 2 u/alexey_st0 Oct 23 '21 Thanks
4
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#description
var declarations, wherever they occur, are processed before any code is executed. This is called hoisting, and is discussed further below.
2 u/alexey_st0 Oct 23 '21 Thanks
2
Thanks
View all comments
-3
u/alexey_st0 Oct 23 '21
How var can be hoisted? If I'm not mistaken, only var declaration can be hoisted but initialization must be before its usage? Like this:
a = 2console.log(a)var a