Favorites

JavaScript typeof Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
typeof
JavaScript Unary OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

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 operand

Example

console.log(typeof 42, typeof 'hi', typeof true);
console.log(typeof undefined, typeof 10n, typeof Symbol());
console.log(typeof {}, typeof [], typeof null);
console.log(typeof function () {});
console.log(typeof notDeclaredAnywhere);

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.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee