Operators
typeof operator
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 expressionParameters & Attributes
| Name | Type | Description |
|---|---|---|
| expression | expression | Operand 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);