prototype chain
The linked list of objects JavaScript searches when looking up a property, which is how inheritance works under the hood.
In more detail
Each object points to a prototype, which points to another, ending at Object.prototype. instanceof walks this chain looking for a class's prototype. Changing shared prototypes affects every object that uses them, so modern code avoids it.
Related terms
- instanceof — The JavaScript operator that checks whether an object was created by a given class, by walking its prototype chain.
- class — A blueprint in code that bundles data and the functions that work on it, from which objects are made.
- inheritance — Declaring one class or type as a specialised version of another, so it receives the parent's members and can be used wherever the parent is expected.
Taught in
- Primitive Types: String, Number, Boolean, Bigint And Symbol — Production TypeScript
- The in Operator And Instanceof Narrowing — Production TypeScript
- Custom Type Predicates: Functions Returning is Type — Production TypeScript
- Modern Decorators: Stage 3 Standards And Class Metadata — Production TypeScript