// variable scope = where a variable is recognized // and accessible (local vs global) let x = 3; // global scope function1(); function function1(){ let x = 1; // local scope console.log(x); } function function2(){ let x = 2; // local scope console.log(x); }
@billionairem4fia
9 ай бұрын
3:27 is a global scope
@LizyAd
5 ай бұрын
This has to be the best explanation for scoping on youtube. I love the examples!
@goodness776
14 күн бұрын
Best incremental teaching! You are a gifted teacher.
@emagenation6409
4 ай бұрын
This is the best and clearest explanation I can get on youtube!! Your reference of neighbour house makes so much sense to me. Thank you, you’re the best teacher bro🙏
@GrayShark09
4 ай бұрын
Yes! Bro Code is a master explainer! I am sure he knows about Feynnman's technique.
@piotrmazgaj
Ай бұрын
This is my seal. I have watched the entire video, understood it, and I can explain it in my own words, thus I have gained knowledge. This is my seal.
@learnwithraj23
Ай бұрын
One of the best explanation thanks Bro
@rajesh_nambi
Ай бұрын
Very Good Explanation.
@buddhavlr1500
10 ай бұрын
Thank you for your tutorials man!
@WisdomInExperience
18 күн бұрын
what about variables declared in other files in global scope ? are they acceible outside that file in global scope ? what is diff between let and var ?
@638_umarsheik8
10 ай бұрын
Great man
@Lail-Albably
6 ай бұрын
really awesome you are the best ever
@ftzah1542
8 ай бұрын
Well done man thanks ❤
@Jvst-bg9wg
10 ай бұрын
Thank you 🎉
@tamekkaknuth9612
10 ай бұрын
Exactly 20000% confident
@cirog.9341
10 ай бұрын
thank you Bro!
@hunin27
10 ай бұрын
Hi Bro, couldn't you declare (even if it's bad practice) a local variable to be global inside of a function? For example in python you do: global x = 5. even if it is declared inside of a function it is now global and accessible everywhere. Much love ❤
@sarcasmclub
Ай бұрын
i know it's been 8 months since you asked but i was just playing with the scope and variable and noticed that if you do not use let ,var ,const to declare a variable inside a function it creates a global variable which can be accessed from anywhere Example: function myFunc() { num = 3; // didn't use var let const before the variable name // also works with function sayhi = function () { console.log("sayHi"); }; } myFunc(); // You have to first call this function // not calling will result in not defined console.log(num); // it prints the value i.e, 3 even though num is inside function myFunc sayhi(); // you can call this function without error // Not using "let" "const" "var" when declaring variable inside function creates global variables
@DamianDemasi
5 ай бұрын
Variables defined with `let` aer scoped to blocks and functions, and can be reassigned Variables defined with `const` are scoped to blocks and functions, and cannot be reassigned Variables defined with `var` are scoped to functions or global (if define in block), and it can be reassigned ``` // Block { var aVar = 1; console.log('aVar', aVar); let aLet = 2; console.log('aLet', aLet); const aConst = 3; console.log('aConst', aConst); } console.log('aVar', aVar); // console.log('aLet', aLet); // Fails // console.log('aConst', aConst); // Fails // Function function myFunc() { var aFuncVar = 10; console.log(aFuncVar); } myFunc(); // console.log(aFuncVar); // Fails ```
Пікірлер: 20