Learn JavaScript VARIABLE SCOPE in 5 minutes! 🏠

  Рет қаралды 11,560

Bro Code

Bro Code

8 ай бұрын

// 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);
}

Пікірлер: 14
@BroCodez
@BroCodez 9 ай бұрын
// 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
@billionairem4fia 6 ай бұрын
3:27 is a global scope
@LizyAd
@LizyAd 3 ай бұрын
This has to be the best explanation for scoping on youtube. I love the examples!
@emagenation6409
@emagenation6409 2 ай бұрын
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
@GrayShark09 2 ай бұрын
Yes! Bro Code is a master explainer! I am sure he knows about Feynnman's technique.
@buddhavlr1500
@buddhavlr1500 8 ай бұрын
Thank you for your tutorials man!
@ftzah1542
@ftzah1542 6 ай бұрын
Well done man thanks ❤
@638_umarsheik8
@638_umarsheik8 8 ай бұрын
Great man
@Jvst-bg9wg
@Jvst-bg9wg 8 ай бұрын
Thank you 🎉
@hmed-Albably
@hmed-Albably 4 ай бұрын
really awesome you are the best ever
@cirog.9341
@cirog.9341 8 ай бұрын
thank you Bro!
@tamekkaknuth9612
@tamekkaknuth9612 8 ай бұрын
Exactly 20000% confident
@hunin27
@hunin27 8 ай бұрын
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 ❤
@DamianDemasi
@DamianDemasi 3 ай бұрын
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 ```
JavaScript TEMPERATURE CONVERSION PROGRAM 🌡️
16:18
Bro Code
Рет қаралды 11 М.
JavaScript reduce() method in 5 minutes! ♻
5:31
Bro Code
Рет қаралды 20 М.
Me: Don't cross there's cars coming
00:16
LOL
Рет қаралды 13 МЛН
Final muy increíble 😱
00:46
Juan De Dios Pantoja 2
Рет қаралды 50 МЛН
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 14 МЛН
What is Scope in Python??
10:25
b001
Рет қаралды 45 М.
Learn JavaScript Scoping In 10 Minutes
11:39
Web Dev Simplified
Рет қаралды 58 М.
Learn JavaScript CLOSURES in 10 minutes! 🔒
10:58
Bro Code
Рет қаралды 13 М.
JavaScript Scope (Local vs Global)
5:43
Programming with Mosh
Рет қаралды 56 М.
JavaScript forEach() method in 8 minutes! ➿
8:02
Bro Code
Рет қаралды 24 М.
Learn JavaScript SORTING in 6 minutes! 🗃
6:42
Bro Code
Рет қаралды 16 М.
Learn JavaScript Hoisting In 5 Minutes
5:40
Web Dev Simplified
Рет қаралды 122 М.
The Importance of THIS in Javascript
22:59
developedbyed
Рет қаралды 21 М.
Learn JavaScript ARROW FUNCTIONS in 8 minutes! 🎯
8:02
Bro Code
Рет қаралды 24 М.
Build this JS calculator in 15 minutes! 🖩
15:20
Bro Code
Рет қаралды 409 М.
Me: Don't cross there's cars coming
00:16
LOL
Рет қаралды 13 МЛН