javascript falsy
snippet in javascript

javascript falsy

user5799

// Falsy values:
0
''
undefined
null
NaN

javascript falsy values

user8449

the number 0
the BigInt 0n
the keyword null
the keyword undefined
the boolean false
the number NaN
the empty string "" (equivalent to '' or ``)

is null falsy javascript

user7354

/*
	Yes.
    Full list of falsy values:
    Anything evaluated to be 0
    '', "", or ``
    null
    undefined
    NaN
    Obviously false
    Big integers relative to 0n
    -------------------------------------------------------------------------
    To clarify, line 31 will print false.
*/
var someCheckIsTrue = false;
const checks = [
  0,
  '',
  "",
  ``,
  null,
  undefined,
  NaN,
  false,
  0n
];
for (const check of checks) {
  if (check) {
    someCheckIsTrue = true;
  }
}
console.log(someCheckIsTrue);

javascript truthy

user3343

// Truthy values:

// All values are truthy, BUT (excluding) the following:
0
''
undefined
null
NaN