Typeof operator
A typeof operator obtains type information about an operand or expression, yielding a type or a string describing its type depending on the language.
Modern C, Third Edition
typeof is a C type operator that derives a type from an expression or type name without evaluating an expression operand.
- How it is used
- Uses type inference to maintain type consistency and support type-generic interfaces.
- How deep it goes
- Explains declarations, evaluation and qualifier cautions, compatibility checks, and multiparameter matching through macro examples.
- Examples
- Uses an inferred declaration, a compatibility assertion macro, a power-function selection macro, and an enumeration with an explicit underlying type.
- What you can do after
- Evaluate type compatibility and construct type-dependent macro selections using typeof and _Generic.
Essential TypeScript 5, Third Edition
The typeof operator is a JavaScript operator that produces a string identifying the type category of a value.
- How it is used
- Identifies a value’s runtime type while demonstrating JavaScript’s dynamic typing.
- How deep it goes
- Demonstrates primitive results and the null exception, but stops short of broader object and function-type behavior.
- Examples
- Uses index.js and index.ts listings that inspect strings, numbers, booleans, undefined, and a changing variable.
- What you can do after
- Diagnose/debug with it by checking a value’s runtime category and spotting unexpected assignments before calculations fail.
Read how Essential TypeScript 5, Third Edition explains typeof operator →
Secrets of the JavaScript Ninja, Third Edition
The JavaScript typeof operator returns a string indicating the basic type of its operand.
- How it is used
- Checks whether a possibly undeclared global exists and reports an operand’s basic type.
- How deep it goes
- Explains global checks, comparison with undefined, and the local-variable Temporal Dead Zone, without detailing all return values.
- Examples
- Uses a typeof guard before assigning a global and contrasts typeof on a class instance with instanceof.
- What you can do after
- Diagnose whether a global identifier is undeclared and recognize when typeof cannot safely check a local variable.
Read how Secrets of the JavaScript Ninja, Third Edition explains typeof operator →
Pro Angular 16
The typeof operator is a JavaScript operator that returns a string identifying the type of its operand.
- How it is used
- Uses runtime checks to validate function arguments and select operations for number, string, or object values.
- How deep it goes
- Demonstrates guards, errors, union-type branches, and object limitations, but defers a complete catalog of returned type strings.
- Examples
- Uses numeric and string function arguments, union-type branches, and Product and DiscountProduct objects.
- What you can do after
- Diagnose unexpected argument types and branch safely before applying type-specific operations.
Also covered in
What to know first
- missing valueA missing value is an expected data value or observation that is absent, unavailable, unknown, or inapplicable.
- integerAn integer is a whole-number mathematical value, including negative numbers, zero, and positive numbers, with no fractional part.
- JavaScriptJavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
- objectAn object is a distinct entity represented or manipulated within a computational system, typically as a value, data structure, resource, or instance of a type.
Related concepts
- tuplecontrasts with · A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
- type assertionalternative to · A type assertion is a language construct that states or checks that a value has a specified type, with runtime behavior depending on the language.
- type guardused by · A type guard is a runtime-checkable condition that enables TypeScript to narrow an expression to a more specific type within a code path.
- type inferenceused by · Type inference is the automatic deduction of program types from expressions, values, declarations, usage, or contextual constraints without requiring every type to be specified explicitly.
- autoalternative to · auto is a language feature that directs the compiler to deduce an object's type from its initializer.
Questions about typeof operator
What is typeof operator?
A typeof operator obtains type information about an operand or expression, yielding a type or a string describing its type depending on the language.
Which Manning books explain typeof operator?
Modern C, Third Edition, Essential TypeScript 5, Third Edition, Secrets of the JavaScript Ninja, Third Edition and Pro Angular 16.
What should I know before learning typeof operator?
Manning books that teach typeof operator usually introduce missing value, integer, JavaScript and object first.
What is the difference between typeof operator and tuple?
A typeof operator obtains type information about an operand or expression, yielding a type or a string describing its type depending on the language. A tuple is a finite, ordered collection of values grouped as a single composite value, often with elements of different types.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



