javascript falsy values
the number 0
the BigInt 0n
the keyword null
the keyword undefined
the boolean false
the number NaN
the empty string "" (equivalent to '' or ``)
3
2
let a = false
let b = 0
let c = -0
let d = 0n
let e = ''
let f = null
let g = undefined
let h = NaN
Thank you!
2
0
3.7
10
if (true)
if ({})
if ([])
if (42)
if ("0")
if ("false")
if (new Date())
if (-42)
if (12n)
if (3.14)
if (-3.14)
if (Infinity)
if (-Infinity)
Thank you!
10
0
0
0
// JS Essentials: Falsy Values
false
undefined
null
NaN
0 or +0 or -0
"" or '' or `` (empty string)
// Everything else is truthy
Thank you!
0
0
4.43
7
false //The keyword false.
0 //The Number zero (so, also 0.0, etc., and 0x0).
-0 //The Number negative zero (so, also -0.0, etc., and -0x0).
0n, -0n //The BigInt zero and negative zero (so, also 0x0n/-0x0n).
"", '', `` //Empty string value.
null //the absence of any value.
undefined //the primitive value.
NaN //not a number.
document.all
//Objects are falsy if and only if they have the [[IsHTMLDDA]] internal slot.
//That slot only exists in document.all and cannot be set using JavaScript.
Thank you!
7
0
4.1
10
// Falsy values:
0
''
undefined
null
NaN
Thank you!
10
0
Are there any code examples left?
New code examples in category Javascript
-
Javascript 2023-04-21 22:52:36
-
Javascript 2022-03-27 22:25:20 javascript download string as file
-
Javascript 2022-03-27 21:40:22 sort numbers in array javascript
-
Javascript 2022-03-27 21:20:04 compare two arrays and return the difference javascript
-
Javascript 2022-03-27 21:15:02 javascript regex french phone number
-
Javascript 2022-03-27 21:05:03 cypress custom error message
-
Javascript 2022-03-27 21:00:05 create element javascript with id
-
Javascript 2022-03-27 20:40:57 feather icons react
-
Javascript 2022-03-27 20:20:01 how to make graphql request in axios
-
Javascript 2022-03-27 20:15:07 bootstrap validator password and confirm password