Тёмный

Learn JavaScript INHERITANCE in 7 minutes! 🐇 

Bro Code
Подписаться 2,1 млн
Просмотров 17 тыс.
50% 1

// inheritance = allows a new class to inherit properties and methods
// from an existing class. Helps with code reusability
class Animal{
alive = true;
eat(){
console.log(`This ${this.name} is eating`);
}
sleep(){
console.log(`This ${this.name} is sleeping`);
}
}
class Rabbit extends Animal{
name = "rabbit";
run(){
console.log(`This ${this.name} is running`);
}
}
class Fish extends Animal{
name = "fish";
swim(){
console.log(`This ${this.name} is swimming`);
}
}
class Hawk extends Animal{
name = "hawk";
fly(){
console.log(`This ${this.name} is flying`);
}
}
const rabbit = new Rabbit();
const fish = new Fish();
const hawk = new Hawk();
console.log(rabbit.alive);
rabbit.eat();
rabbit.sleep();
rabbit.run();

Опубликовано:

 

17 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 19   
Далее
The JavaScript SUPER keyword is super! 🦸‍♂️
9:22
Как мы играем в игры 😂
00:20
Просмотров 188 тыс.
ГОЧА ПРО NISSAN 400Z
00:51
Просмотров 40 тыс.
Prank Orchestra
00:10
Просмотров 1,1 млн
Frontend Web Development Projects that got me hired
10:38
Learn JavaScript ARROW FUNCTIONS in 8 minutes! 🎯
8:02
Build this JS calculator in 15 minutes! 🖩
15:20
Просмотров 546 тыс.
STOP Using Classes In JavaScript | Prime Reacts
14:02
Просмотров 239 тыс.
Array Methods in JavaScript | 17 Useful Methods
42:39
Every React Concept Explained in 12 Minutes
11:53
Просмотров 633 тыс.
Learn Closures In 13 Minutes
13:22
Просмотров 66 тыс.
JavaScript GETTERS & SETTERS are awesome!!! 📐
13:14
JavaScript Pro Tips - Code This, NOT That
12:37
Просмотров 2,5 млн
Как мы играем в игры 😂
00:20
Просмотров 188 тыс.