To create a class inheritance, use the extends keyword.
A class created with a class inheritance inherits all the methods from another calss:
상속으로 만들어진 클래스는 모든 메소드들을 상속받는다. (위 클래스로부터)
To create a class, it is needed a constructor. A constructor has its argument and use this keyword.
클래스 모델은 extends를 통해 Car를 상속받고, super keyword를 통해 brand 값을 물려 받는다.
The super() method refers to the parent class.
By calling the super () method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods.
Inheritance is useful for code reusability: reuse properties and methods of an existing class when you create a new class.
Classes also allows you to use getters and setters.
It can be smart to use getters and setters for your properties, especially if you want to do something special with the value before returning them, or before you set them.
To add getters and setters in the class, use the get and set keywords.
Note: even if the getter is a method, you do not use parentheses when you want to get the property value.
The name of the getter/setter method cannot be the same as the name of the property, in this case carname.
Many programmers use an underscore character _ before the property name to separate the getter/setter from the actual property:
Unlike functions, and other JavaScript declarations, class declarations are not hoisted
That means that you must declare a class before you can use it: