Truthy & Falsey values
Video
JavaScript Notes
JavaScript
// Truthy & Falsey in JavaScript
// Boolean-ish
// null, undefined, 0, false, '', "", NaN – FALSEY
let log = console.log;
let bob; // undefined
let es = "";
let z = 0;
let n = null;
let u = undefined;
let f = false;
let i = !isNaN("hello");
if (es || z || n || u || f || i) {
log('The true part')
} else {
log('The false part') // will always return this
}
Feedback
Submit and view feedback