An instanceof check tests a constructor relationship. Deserialized records do not automatically regain the class prototype.
Worked example
class Invoice {}
const value = new Invoice();
console.log(value instanceof Invoice, {} instanceof Invoice);Result
true falseImplementation notes
A constructor check can change across frames or separately loaded copies of a package. An explicit discriminant is often a better identity for exchanged data.
Try it yourself
Compare an instance with its JSON round trip.
Open the JavaScript example →Editorial date August 30, 2025 · Published December 6, 2026