JavaScript typeof Operator
The typeof operator returns a string naming the type of a value, such as "number", "string" or "object".
Description
The typeof operator returns a string indicating the type of its operand: "undefined", "boolean", "number", "bigint", "string", "symbol", "function" or "object". It's safe to use on variables that were never declared, which makes it useful for feature detection.
Two quirks: typeof null is "object" (a historic bug), and arrays are also "object", so use value === null and Array.isArray() for those.
Because typeof doesn't throw for undeclared variables, it's the classic way to check for optional features, such as typeof structuredClone === 'function'. It does throw for let, const and class names used before their declaration, because of the temporal dead zone. Classes report "function", since they are functions under the hood.
Properties
- Operator
typeof- Category
- Unary
- Precedence
- 14 (1 is lowest, 18 is highest)
- Associativity
- right-to-left
Syntax
typeof operandExample
Browser Support
The following information will show you the current browser support for the typeof operator. Hover over a browser icon to see the version that first introduced support for this operator.
Desktop





Tablets & Mobile





