SpinTheMic
Pro

Interview practice question

A subclass constructor throws an error about this

Frontend Engineering · JavaScript Core · Intermediate

A subclass constructor throws "Must call super constructor before accessing this." Why, and how do you fix it?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Derived classes must call super() first.
  • this not initialised until super runs.
  • Pass required args to super.
  • Class fields initialised after super.
  • Consider composition.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics