DEV Community

Discussion on: Hoist Your Vars! (Variable Hoisting in JavaScript)

Collapse
 
mitri45 profile image
Dmitrii Bludov

Thanks for Hoist explanation, but as a newbie I'm a little confused about your statement of "NEVER use var".
Since now, I thought that main differences between var and let/const lay in the scope field and they visibility in current execution context.
What havoc exactly var statement could wreak? In case of hoisting - is it better not to avoid var, but to avoid havoc in code by assuming that JS is single thread execution scripting language?

And another question that I have after reading - the words "compilation phase". Do we really have compilation process in scripting language?

Collapse
 
moyarich profile image
Moya Richards

Your questions are addressing too many things. You are talking about scope, execution context, thread, compilation. These are things that you must understand fully. I think that you would benefit from watching this video. please pay for the full course, it will greatly improve your JavaScript skills. Tony teaches about all these things.

youtube.com/watch?v=Bv_5Zv5c-Ts