JavaScript · Middle · Question 9 of 75

Why must a subclass constructor call super() before accessing this?

Explanation

In a derived class, the instance is created by the parent constructor, so accessing this before super() throws a ReferenceError. The parent's methods aren't copied - they're available through the prototype.

Further reading

Problem with a question

JavaScript · Middle · question 9

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz