⏱ 0:01est. 3 min
Var Let Const Block Scope Shadowing
// https://www.youtube.com/watch?v=BNC6slYCj50&list=PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP&index=9&ab_channel=AkshaySaini
// https://www.youtube.com/watch?v=lW_erSjyMeM&feature=emb_logo&ab_channel=AkshaySaini
var a = 100;
let b = 200;
const c = 300;
{
var a = 1; // a is shadowing 'a' in line 1 (both 'a' are pointing to same memory location) // GLOBAL memory
let b = 2; // block memory
const c = 3; // block memory
console.log(a); // 1
console.log(b); // 2 // shadowing because of block memory
console.log(c); // 3 //
}
console.log(a); // 1 shadowed and modified line 1, both 'a' are pointing to same memory location)
console.log(b); // 200 // Not shadowing because of block memory, diff memory space
console.log(c); // 300 // Not shadowing because of block memory, diff memory space