-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathletvsconst.js
More file actions
69 lines (32 loc) · 1.1 KB
/
letvsconst.js
File metadata and controls
69 lines (32 loc) · 1.1 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// JavaScript let keyword vs const keyword
// let keyword lets us create or declair and reassign a value later
// let provides block level scoping
// ability to reassign a value
const id = 'xyz123';
let highFives = 23;
let isCool = false;
// the let lives on different block scope
if (highFives > 5) {
let isCool = true;
console.log('Inside of the IF', isCool);
}
console.log(isCool);
// reassigned a new value to highFives
// block scoping
/*highFives= 25;
console.log(highFives);*/
// cant do this because the highFives have been declared at the same block level.
/*let highFives = 25;
console.log(highFives);*/
******************************************************************************************
// const can not be reassigned a new value
/*id = 'abc123';
console.log(id);*/
// while working with objects, we want to update object properties
// you cannot update person object but you can update the properties of the object
// the const variable can never be updated
const person = {
name: 'Jason';
age: 25;
}
person.age = 26;