Truthy values in JavaScript


Everything else is considered true:


The string " " with a single space
Infinity
The string "0"
The string "false"


examples/js/truthy.js
"use strict";

console.log('start');

if (42) {
  console.log('The number 42');
}

if (' ') {
  console.log('The string " " with a single space');
}

if (Infinity) {
  console.log('Infinity');
}
if ('0') {
  console.log('The string "0"');
}

if ('false') {
  console.log('The string "false"');
}

console.log('end');