JSFiddle - React, Tailwind, and code Playground
JavaScript
const a = undefined;
const b = null;
const c = -1 // false
const d = 0 // true
const e = 1 // true
test(a)
test(b)
test(c)
test(d)
test(e)
function test(myvar) {
const converted = (myvar ?? myvar)
if (converted) {
/* console.log(myvar, converted, 'is truthy') */
}
}
test2([a, b, c, d, e])
function test2(vars) {
vars.forEach(x => {
const isNum = ''
console.log(!!+converted, converted)
})
}