-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy path06 - Comparisons.html
70 lines (57 loc) · 1.83 KB
/
06 - Comparisons.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Getting Started with JavaScript</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<style>
body {
padding: 30px;
}
</style>
</head>
<body>
<!-- 🔥🔥🔥🔥 start javascript 🔥🔥🔥🔥 -->
<script>
const original = 'chris';
const clone = 'CHRIS';
console.groupCollapsed('String');
console.log(original == 'chris'); // true
console.log(original == clone); // false
console.log(original == clone.toLowerCase()); // true
console.groupEnd();
const num1 = 10;
const num2 = '10';
console.groupCollapsed('Numbers');
console.log(num1 == num2); // true
console.log(num1 === num2); // false
console.log(num1 != num2); // false
console.log(num1 !== num2); // true
console.groupEnd();
let what; // undefined
let thing = null;
console.groupCollapsed('Booleans');
console.log(Boolean(what)); // false
console.log(Boolean(thing)); // false
console.log(Boolean(num1)); // true
console.log(Boolean(num2)); // true
console.log(Boolean({})); // true
console.log(Boolean([])); // true
console.groupEnd();
const firstArr = [1, 2, 3];
const secondArr = [1, 2, 3];
const firstObj = { color: 'red' };
const secondObj = { color: 'red' };
console.groupCollapsed('Objects and Arrays');
console.log(firstArr === secondArr);
console.log(firstObj === secondObj);
console.groupEnd();
console.group('And Or');
console.log(Boolean('blah') && Boolean('thing')); // true
console.log(Boolean('blah') && Boolean('')); // false
console.log(Boolean('blah') || Boolean('')); // true
console.log(Boolean('') || Boolean('')); // false
console.groupEnd();
</script>
</body>
</html>