JavaScriptBeginner#coercion

What are truthy and falsy values?

Falsy values are false, 0, -0, 0n, '', null, undefined and NaN. Everything else is truthy, including '0', 'false', [] and {}.

Example
if ([]) console.log('empty array is truthy'); // prints
Boolean('0');   // true
Boolean(NaN);   // false

Related Questions

1
JavaScriptIntermediate#this#functions

How does 'this' work in JavaScript?

Open
2
JavaScriptIntermediate#functions#this

Difference between call, apply and bind?

Open
3
JavaScriptIntermediate#functions#es6

Difference between arrow functions and regular functions?

Open