JavaScript OOP တွင် method ၏ မူရင်းကုဒ်

class ၏ method တစ်ခု၏ မူရင်းကုဒ်ကို ကွင်းဝိုင်းများမပါဘဲ လှည့်ကိုက်လျှင် ရရှိနိုင်သည်။ စမ်းကြည့်ကြပါစို့။ အောက်ပါ class ရှိသည်ဆိုပါစို့:

javascriptclass User {
  #name;
  
  constructor(name) {
    this.#name = name;
  }
  getName() {
    return this.#name;
  }
}

ဤ class ၏ object တစ်ခုကို ဖန်တီးကြမည်:

javascriptlet user = new User('john');

method ၏ မူရင်းကုဒ်ကို ထုတ်ပြမည်:

javascriptconsole.log(user.getName);
Задание 1

Employee class ၏ method တစ်ခုခု၏ မူရင်းကုဒ်ကို ထုတ်ပြပါ။