Classes and modules in OOP in JavaScript

Typically, each class is placed in a separate module. In this case, the name of the module file must match the name of the stored class. Let's place our class User in the corresponding file:

User.jsexport default class User {
  #name;
  
  constructor(name) {
    this.#name = name;
  }
  getName() {
    return this.#name;
  }
}

In the file index.js we import our class:

index.jsimport User from './User.js';

Now we can work with our class in this file:

index.jslet user = new User('john');
Задание 1

Place the Employee class in a separate file.

Задание 2

In the index.js file, create an object of this class.