-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05_let_const.js
44 lines (33 loc) · 1.13 KB
/
05_let_const.js
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
/*-----------------------------------------------------------------------------*/
// Let VS Const
// https://medium.com/javascript-scene/javascript-es6-var-let-or-const-ba58b8dcde75
/*------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
/* Let (ES6)
-------------------------------------------------------------------------------*/
// let a = "Var a"
// let b = "Var b"
// // Let can only be accessed in the Block scope
// {
// let a = "New var a"
// let b = "New Var b"
// console.log(a, b);
// }
// console.log(a, b);
/*-----------------------------------------------------------------------------*/
/* Const cannot be reassigned
-------------------------------------------------------------------------------*/
// Error
// const PORT = 8888;
// PORT = 2000;
// Elements inside of arrays and objects CAN be changed
const array = ["JavaScript", "is", "awesome"]
array.push("!");
array[0] = "JS";
//Error
array = ["JavaScript", "is", "awesome"]
console.log(array);
const obj = {}
obj.name = "Dima"
obj.age = 26
console.log(obj);