VIDEO 21 javascript

PHOTO EMBED

Tue Oct 29 2024 21:05:18 GMT+0000 (Coordinated Universal Time)

Saved by @E23CSEU1151

///////////////***** SCOPES IN JS *************/////////////

let a = 200
if(true){
    let a = 100
    console.log("inner a is  ",a);// 100 (BLOCK SCOPE)
}
console.log("outer a is  ",a); // 200 (GLOBAL SCOPE)

/*

BLOCK SCOPE 
The space inside the curly braces is called a block space.
variable assigned in block scope only accessable in block scope not in global scope.


Global SCOPE 
The space outside the curly braces is called a Global space.
variable assigned in global scope  accessable in both block scope and  global scope.

*/
content_copyCOPY