typeof
Returns the type of a value.
Syntax
typeof value
Description
Returns the type of the value as a string: "number", "string", "boolean", "object", "undefined", "function".
Returns
Type name (string).
Example
Loading editor…
Expected output
number string boolean
When to use?
Checking the type of incoming data, debugging.
Common mistakes
- ⚠️ typeof null → returns 'object' (a historical quirk of the language).