Inheritance and super
extends connects class inheritance, and super calls or accesses parent behavior. A derived constructor must initialize this through super before using this.
Reuse a parent’s initialization, then add the child’s specific state.
See the mechanism
new FeaturedArticle("Morning")Follow one example
super(title) runs the parent constructor for the new derived instance. The child then adds featured. Its prototype chain makes parent methods available when not overridden. Inheritance models an is-a relationship; composing separate behaviors is often clearer when one object merely uses another.
Predict, change and check
Predict: What fails if this.featured = true is placed before super(title)?
Test your explanation: Test the constructor order, then restore it. Add a parent method and compare an inherited call with a deliberate child override.
The tasks below ask you to explain that result and apply the idea to different inputs.
Apply and distinguish
Extend behavior without confusing storage
extends establishes the class and prototype relationships used for inheritance. A derived constructor must call super before using this. An overridden method can call super.method to reuse parent behavior, but that is a specific method lookup, not a second independent object embedded in the instance.
Use inheritance for a compatible behavioral relationship rather than to avoid writing two similar lines. An inherited method can still operate on the derived receiver. Test the base behavior, the override and an inherited property lookup, and inspect which fields are actually own properties of the instance.
Check your understanding: State the input contract, identify the operation that changes the result, and give one boundary input that would distinguish the correct rule from the mistake described above.