Instanceof operator
The instanceof operator tests whether an object or reference is compatible with a specified runtime type or constructor according to the programming language’s rules.
Secrets of the JavaScript Ninja, Second Edition
A JavaScript operator that tests whether an object was created by, or inherits from, a particular constructor via its prototype chain.
- How it is used
- Tests whether an object participates in a constructor’s prototype-based inheritance chain.
- How deep it goes
- Works through prototype-chain matching and shows how replacing a constructor’s prototype reverses an existing object’s result.
- Examples
- Contrasts copied methods with inherited prototypes and tests an existing instance before and after prototype replacement.
- What you can do after
- Diagnose/debug with it: explain a surprising type-check result by inspecting the constructor’s current prototype and the object’s chain.
Read how Secrets of the JavaScript Ninja, Second Edition explains instanceof operator →
100 Java Mistakes and How to Avoid Them
- How it is used
- Guards downcasts and dispatches runtime-type-specific behavior while preventing overlapping conditional branches.
- How deep it goes
- Explains subtype matching through branch-order failures and contrasts it with exact runtime-class comparisons.
- Examples
- Uses BigInteger and BigDecimal conversion, date conversion, ArrayList checks, and Calendar instances.
- What you can do after
- Diagnose/debug with it by finding unreachable type branches and choosing subclass-compatible versus exact-class tests.
Read how 100 Java Mistakes and How to Avoid Them explains instanceof operator →
Related concepts
- prototype chainuses · A prototype chain is the linked sequence of JavaScript prototype objects consulted during property lookup when an object lacks the requested property itself.
- pattern matchingused by · Pattern matching is the process of comparing values, structures, or other data with specified or learned patterns to determine correspondence, often enabling classification, extraction, or selection of behavior.
- classuses · A class is a programming-language construct that defines a type’s structure or behavior and provides a basis for creating or representing objects.
- getClasscontrasts with · getClass is the Java Object method that returns the runtime class object of the instance on which it is invoked.
- constructor methoduses · A constructor is a type-associated operation or callable that creates or initializes an instance and establishes its initial state.
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.

