JavaScript Tutorial - Creating Sub-classes

Опубликовано: 13 Октябрь 2017
на канале: Struct Feed
1,565
15

In this video I go over creating subclass or derived classes in javascript.

When you create a class with the "extends" keyword, those classes are called derived classes or subclasses.

To declare a subclass You first write the "class" keyword, followed by the name you want to give your class. Then you write "extends" keyword and after extends goes the class you wish to extend

class square extends shape {
}

Now the subclass can access the properties and methods of parent class as if they were defined in the new class

The derived class can refer to the parent class (ie. the class it extends), you can use "super" keyword.

Your derived class must call super() in the custructor.

class square extends shape {
constructor(color) {
super("square", color);
}
}

You can have no constructor as well

to call a method in parent class use "super.methodname()"


На этой странице сайта вы можете посмотреть видео онлайн JavaScript Tutorial - Creating Sub-classes длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Struct Feed 13 Октябрь 2017, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,565 раз и оно понравилось 15 зрителям. Приятного просмотра!