Skip to content

Instantly share code, notes, and snippets.

@drteresavasquez
Created February 27, 2026 21:29
Show Gist options
  • Select an option

  • Save drteresavasquez/7f4caa42842ae4af54bf727ddaf72258 to your computer and use it in GitHub Desktop.

Select an option

Save drteresavasquez/7f4caa42842ae4af54bf727ddaf72258 to your computer and use it in GitHub Desktop.
The typeof Operator — What It Gets Right and Wrong
console.log(typeof "hello"); // "string"
console.log(typeof 42); // "number"
console.log(typeof true); // "boolean"
console.log(typeof undefined); // "undefined"
console.log(typeof Symbol()); // "symbol"
console.log(typeof 42n); // "bigint"
console.log(typeof function(){}); // "function"
// The two that will catch you off guard
console.log(typeof null); // "object" ← 30-year-old bug, never fixed
console.log(typeof []); // "object" ← arrays look like objects too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment