JavaScript Introducing ES2015 Classes Sub-Classes

order of classes

im pretty confused. how come the Student class cannot be declared before the person class? Maybe there is something i didn't understand. I thought I understood hoisting. it was basically to define the class before calling the class. I don't see how a different order of classes affect anything as long as you call them after they are both defined. Please and Thank you for the help.

1 Answer

Steven Parker
Steven Parker
201,292 Points

You're right that you should define a class before you call it. But that's not "hoisting" .. and in fact class declarations are not hoisted in JavaScript.

The issue here is "dependency", which means that you should always define a class before any others that reference it. Since a Student is a special kind of Person then Person needs to be defined first.