JS Built-ins
TypeCoercionbeginner

Boolean Coercion (Truthy/Falsy)

Boolean Coercion: Truthy and Falsy

Falsy values: false, 0, '' (empty string), null, undefined, NaN

Everything else is truthy, including:

  • Non-zero numbers: 1, -1, 0.1
  • Non-empty strings: '0', 'false'
  • Empty arrays: []
  • Empty objects: {}

Boolean(value) converts to explicit boolean.

Challenge: Convert values to boolean using Boolean() and observe truthy/falsy behavior.

πŸ’‘ Hints (3)
  • β€’ Falsy: false, 0, "", null, undefined, NaN
  • β€’ Empty arrays and objects are truthy, not falsy.
  • β€’ Only the 6 falsy values coerce to false; everything else is truthy.