-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (25 loc) · 805 Bytes
/
Copy pathscript.js
File metadata and controls
37 lines (25 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* There are three type of Scope:
1.Block Scope
2.Golbal Scope
3.Functional Scope
Two main scopes let and const which are block scope were introduced after ES6
*/
// First we will discuss Block Scope
var a = 2;
console.log(a);
let b = 3;
console.log(b);
const c = 4;
console.log(c);
// Now we will discuss about Functional Scope
function Scope() {
let d = 3; //In functional scope the variable are declared inside the function and cannot be accessed outside
console.log(d);
}
// Global Scope
let e = 9; // In Global Scope variables are Global they can accessed inside a function and anywhere in the Program
function Display() {
console.log(e);
}
console.log(e);
// Do not try to use Global Scope Unless you intend because your global variables and functios can overwrite the window