-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboolean.js
More file actions
106 lines (75 loc) · 1.59 KB
/
boolean.js
File metadata and controls
106 lines (75 loc) · 1.59 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//javaScript Booleans
{
let x = 0;
let z = "Shawn";
let y = Boolean(x);
console.log(y);
console.log(Boolean(z));
}
{
//There are 7 things in JS Booleans that return false(and it's known as falsy value)
///1)The Boolean value of 0 (zero) is false:
///2)The Boolean value of -0 (minus zero) is false:
///3)The Boolean value of "" (empty string) is false:
///4)The Boolean value of undefined is false:
///5)The Boolean value of null is false:
///6)The Boolean value of 'false'(you guessed it) false:
///7)The Boolean value of 'NaN' is false:
}
{
//Everything With a "Value" is True
{
let x = true;
console.log(x);
}
{
let x = 100;
console.log(Boolean(x));
}
{
let y = 3.14;
console.log(Boolean(y));
}
{
let z = "false";
console.log(Boolean(z));
}
{
const math_calculation = 7+1+3.14;
console.log(Boolean(math_calculation));
}
}
{
//Everything Without a "Value" is False
{
let x = "";
console.log(Boolean(x));
}
{
const b = NaN;
//or
const d = 10/"Apple";
console.log(Boolean(b));
console.log(Boolean(d));
}
{
let a;
console.log(Boolean(a));
}
{
let c = false;
console.log(Boolean(c));
}
{
const nul = null;
console.log(Boolean(nul));
}
{
const zero = 0;
console.log(Boolean(zero));
}
{
let e = -0;
console.log(Boolean(e));
}
}