Operators

typeof operator

Try the free JavaScript compiler

Produces a string type tag, including function for callable objects and object for null. Ordinary undeclared bare names return undefined as a tag; an uninitialized lexical name still throws ReferenceError. The legacy browser document.all behavior is exceptional.

Formal Syntax & Structure

javascript syntaxjavascript
typeof expression

Parameters & Attributes

NameTypeDescription
expressionexpressionOperand to evaluate, or bare identifier for special lookup behavior.

Return Value

string

Runtime type tag, not a complete object classification.

Working Example

Example Snippetjavascript
console.log(typeof null);console.log(typeof 3n);
JavaScript Reference