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
- Supplies expression-derived types for generic macros, type checks, result conversions, and an explicit enumeration underlying type.
- How deep it goes
- Works through declarations and macro type matching, including evaluation and qualifier cautions, rather than detailing every typeof edge case.
- Examples
- Uses a declaration inferred from `3*x`, a static-assertion compatibility macro, and an enumeration typed from a decimal constant.
- What you can do after
- Build it from scratch: use typeof with _Generic to check macro-argument types without evaluating the arguments.
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 →
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.
Related concepts
- type inferenceused by · Type inference is the automatic deduction of program or expression types from available values, context, and constraints without requiring explicit type annotations.
- 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.
- tuplecontrasts with · A tuple is a finite, ordered collection of elements treated as a single composite value or record.
- 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.
- objectcontrasts with · A computational object is a runtime entity or structured value representing data, state, or a resource, with properties or operations defined by its programming model.
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.


