Created
February 27, 2026 21:29
-
-
Save drteresavasquez/7f4caa42842ae4af54bf727ddaf72258 to your computer and use it in GitHub Desktop.
The typeof Operator — What It Gets Right and Wrong
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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