JavaScript
JavaScript typeofJavaScript typeof
JavaScript typeof identifies the data type of a variable.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
JavaScript uses the `typeof` operator to figure out what kind of data a variable holds. Because JavaScript variables can hold anything, developers use this tool to check the data type before running specific functions.
Example
Example
Key Points
- `typeof` returns the data type as a lowercase string.
- It identifies strings, numbers, booleans, and objects.
- Arrays return as "object" because they are a special object type.
- Undefined variables return as "undefined".