-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock,Scope and blockScope.js
More file actions
23 lines (23 loc) · 1.03 KB
/
Block,Scope and blockScope.js
File metadata and controls
23 lines (23 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//block
var b=9;//global scope
let a=8;//script scope
{ //block nothing but putting multiple javascript statemnt together inside block where javascript excepts one single satement n=by this if we define let and consta in block it will be removed once the block execution is done by this way we can say let and const block scope but var is global scope
let a=10;//block
var b=20;//global scope
const c=30;//block
console.log(a);
console.log(b);
console.log(c);
}
//it behavious same as block(function scope)
function sample(){ //block nothing but putting multiple javascript statemnt together inside block where javascript excepts one single satement n=by this if we define let and consta in block it will be removed once the block execution is done by this way we can say let and const block scope but var is global scope
let a=10;//block
var b=20;//global scope
const c=30;//block
console.log(a);
console.log(b);
console.log(c);
}
console.log(a);//from script
console.log(b);//20
console.log(c); //not defined