-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay1.js
More file actions
83 lines (62 loc) · 1.85 KB
/
Day1.js
File metadata and controls
83 lines (62 loc) · 1.85 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//* Variable and DataTypes
var math = 10;
// console.log(math)
let name = "Chai"
// console.log(name)
const answer = false
// console.log(answer)
const arr = [1, 2, 3, 4, 5, 6]
const obj = {
firstName: 'faisal',
lastName: 'Khan'
}
// console.log(typeof math)
// console.log(typeof name)
// console.log(typeof answer)
// console.log(typeof arr)
// console.log(typeof obj)
let lumber1 = 12
console.log(lumber1)
lumber1 = 13
console.log("after resign::", lumber1)
const lumber2 = 99
// console.log(lumber2)
// lumber2 = 100;
// console.log(lumber2) //! gives an error because can't reassign value to the const.
let numbers = 12;
let names = "Faisal Khan"
let functionName = function () {
console.log("hello from Function")
}
let nullvalue = null;
let trueValue = true;
let arr1 = [1, 2, 3, 4, 5, 6, 7]
let obj1 = {
name: 'FaisalKhan',
contact: '0315578abc',
}
let symbolVariable = Symbol("symbol");
let bigINTabc = BigInt(3165151);
console.log("number:", typeof numbers)
console.log("number:", typeof names)
console.log("number:", typeof functionName)
console.log("number:", typeof arr1)
console.log("number:", typeof obj1)
console.log("number:", typeof symbolVariable)
console.log("number:", typeof bigINTabc)
//!!! Different behaviour between const and let
// Using let
let variableLet = 10;
console.log("Initial value of variableLet:", variableLet); // Outputs: 10
// Reassigning the let variable
variableLet = 20;
console.log("Reassigned value of variableLet:", variableLet); // Outputs: 20
// Using const
const variableConst = 30;
console.log("Initial value of variableConst:", variableConst); // Outputs: 30
// Attempting to reassign the const variable
try {
variableConst = 40; // This will cause an error
} catch (error) {
console.error("Error when reassigning variableConst:", error.message); // Outputs: Assignment to constant variable.
}