JavaScript

Tests

  • Falsy: !!value or Boolean(value)
  • NaN: Number.isNaN(value)
  • Null or Undefined: value == null (double-equals)
  • Null only: value === null
  • Undefined only: typeof(value) == 'undefined'

Modules

export function foo() {}

export const bar = () => {};

const baz = () => {};
export default baz;

export default function baz() {};

// INVALID
export default const qux = () => {};

Regex

if (/regex/.test(string)) {
}

Utilities

function range(start, end) {
  return Array.from({ length: end - start + 1 }, (_, i) => start + i)
}