Answers for "truthy and falsy values in javascript"

4

javascript falsy

// Falsy values:
0
''
undefined
null
NaN
Posted by: Guest on December-08-2020
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)
Posted by: Guest on January-30-2021
0

Truthy and Falsy js

//Checking truthy and falsy value

function truthyOrFalsy (val) { 
    if(val) {
      return true
    } else {
      return false
    }
}

console.log(truthyOrFalsy(0)) // print false
console.log(truthyOrFalsy(5)) // print true
Posted by: Guest on April-29-2020
0

javascript truthy

// Truthy values:

// All values are truthy, BUT (excluding) the following:
0
''
undefined
null
NaN
Posted by: Guest on December-08-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language