TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
typeof operator is a unary operator that evaluates its operand and returns a string value representing the underlying JavaScript data type of that operand.
Syntax
The operator can be applied with or without grouping parentheses. The parentheses act as standard mathematical grouping operators, not as function invocation.Return Values
The ECMAScript specification restricts thetypeof operator to returning one of eight specific string values.
| Operand Type | Return Value |
|---|---|
| Undefined | "undefined" |
| Null | "object" |
| Boolean | "boolean" |
| Number | "number" |
| BigInt | "bigint" |
| String | "string" |
| Symbol | "symbol" |
Function (implements [[Call]]) | "function" |
| Any other Object | "object" |
Syntax Visualization
Technical Quirks and Edge Cases
Thenull Bug
0. null was represented as the NULL pointer (which is 0x00 on most platforms). Consequently, null had an object type tag, causing typeof to return "object". This behavior is permanently retained in the ECMAScript specification for backward compatibility.
Not-A-Number (NaN)
NaN is a numeric data type defined by the IEEE 754 floating-point standard. Therefore, the engine evaluates it as a number.
Undeclared Variables vs. Temporal Dead Zone (TDZ)
Applying typeof to an undeclared variable is the only way to safely read or evaluate it without throwing a ReferenceError. It safely returns "undefined".
let or const that are currently in the Temporal Dead Zone (TDZ). Attempting to evaluate them before initialization will throw an error.
document.all is a host object that implements a special [[IsHTMLDDA]] internal slot. The ECMAScript specification explicitly dictates that typeof must return "undefined" for objects implementing this slot, primarily to support legacy browser detection code.
Master JavaScript with Deep Grasping Methodology!Learn More





