Metódy tried v OOP v JavaScripte
V triedach je možné vytvárať aj metódy. Vytvorme v našej triede testovaciu metódu:
javascriptclass User {
show() {
return '+++';
}
}
Vytvorme objekt našej triedy:
javascriptlet user = new User;
A teraz zavolajme našu metódu:
javascriptconsole.log(user.show()); // vypíše '+++'
Задание 1
Vytvorte vo vašej triede
Employee nejakú
testovaciu metódu. Zavolajte ju.