I’m trying to check if a number exists and if it does, whether the value is zero or something else. Checking for zero though always returns zero instead of a boolean value.
const example = 0
console.log( example === 0 ) // true
console.log( example && example !== 0 ) // 0
console.log( example && example === 0 ) // 0
I know this may have something to do with zero being falsy in JS but I don’t understand why it evaluates to 0 in the two last cases – if anything, shouldn’t it evaluate to false?