-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtypeCoercion.js
More file actions
31 lines (24 loc) · 763 Bytes
/
typeCoercion.js
File metadata and controls
31 lines (24 loc) · 763 Bytes
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
let x
console.log(x, typeof x) ////JAVASCRIPT TRY TO CONVERT DATA TYPES INTO IT'S OWN WAY
x = 5
x = x + ""
console.log(x, typeof x)
x = x - 2
console.log(x, typeof x)
x = +x + 2
console.log(x, typeof x)
x = !x //not operator
console.log(x, typeof x)
let y = parseInt("7003 Sayantan")
console.log(y)
console.log(Boolean(10)) // ANY NUMBER EXCEPT 0 IS TRUE //TRUTHY VALUE
//BELOW EVERYTHING IS FALSE //FALSY VALUE
// console.log(Boolean(0))
// console.log(Boolean(-0))
// console.log(Boolean(BigInt(0)))
// console.log(Boolean(0n))
// console.log(Boolean("")) // ONLY EMPTY STRING IS FALSE
// console.log(Boolean(undefined))
// console.log(Boolean(null))
// console.log(Boolean(NaN))
// console.log(Boolean(false))