truthy values in js code example

Example 1: javascript truthy

// Truthy values:

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

Example 2: truthy and falsy values in javascript

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)

Example 3: JS truthy value of void

//////////////////////////////////////////////
//      Truthy value of void is false
//////////////////////////////////////////////

function coolFunction() {
  // do stuff
}

let truthyValue = (coolFunction() == true)		// false