OOP-da metodiň gelip çykyş kody JavaScript
Metod klasyna ýaýlanylmajaklyk bilen ýüzlenilse, onuň gelip çykyş kodyny almak mümkin. Geliň synanyşalyň. Bizde aşakdaky klas bolsun:
class User {
#name;
constructor(name) {
this.#name = name;
}
getName() {
return this.#name;
}
}
Bu klasyň obýektini döreteliň:
let user = new User('john');
Metodiň gelip çykyş kodyny görkezeliň:
console.log(user.getName);
Employee klasyňyň haýsydyr bir metodunyň gelip çykyş kodyny görkeziň.