Accessor Getters in OOP in JavaScript

Let's take a closer look at the use of accessor property getters. Let's say we have the following class with a private property:

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

Let's make a public property name in this class that can be read but not written:

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

Let's check the work. Let's create an object of our class, passing it the name value as a parameter:

javascriptlet user = new User('john');

Now let's read the name through the public property:

javascriptlet name = user.name;
console.log(name);

But trying to write down the name will result in an error, just as we wanted:

javascriptuser.name = 'eric';
Задание 1

Implement accessor getters for the properties of the Employee class.