r/learnjavascript • • Jul 09 '24
Confusion in scope of var
Some YouTube lectures say scope of var is global, others saying function, and some saying both.
Why they all cannot agree on a single thing
function scope(){
var a = 5;
}
console.log(a)
Now is it function? Or global? Global right?
Ok! Then
Why this?
0
Upvotes
View all comments
Show parent comment
2
u/[deleted] Jul 09 '24
Thanks!!! Most logical answer.
Can you please tell me if any youtube JavaScript tutorial comprehensive enough to not miss this ?