javascript falsy code example
Example 1: 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 ``)
Example 2: javascript falsy
0
''
undefined
null
NaN
Example 3: falsy javascript
false
0
""
undefined
null
NaN
Example 4: is null falsy javascript
var someCheckIsTrue = false;
const checks = [
0,
'',
"",
``,
null,
undefined,
NaN,
false,
0n
];
for (const check of checks) {
if (check) {
someCheckIsTrue = true;
}
}
console.log(someCheckIsTrue);
Example 5: javascript truthy
0
''
undefined
null
NaN