-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariables.js
More file actions
52 lines (35 loc) · 834 Bytes
/
Copy pathVariables.js
File metadata and controls
52 lines (35 loc) · 834 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// let
// This is a local variable type
// type 1
let age = 21;
console.log(age);
// type 2
if (true){
let age = 21;
}
console.log(age);
// Here the age outside if will not work because the let is local type
//var
//This is a global type
// type 1
var name = "Afaq Ahmed";
console.log(name);
// type 2
if (true){
let name = "Afaq Ahmed";
}
console.log(name);
//No error becaue the var is global nad output "Afaq Ahmed" will be shown
// const
//This is a Permanent type as when it is used the value cannot be changed
// type 1
const gender = "male";
console.log(gender);
// type 2
if (true){
const gender = "male";
}
console.log(gender);
const gender = "female";
console.log(gender);
// Here the error will be shown as the gender is const and cannot e