Why do we need to use "this" keyword when creating properties in classes

Hey there everyone,

So , from what I have learned when creating objects you use the “this” keyword when you want to acess a variable or function inside the object you are creating to avoid scope problems.
You dont need it when you are creating a key/value pair.

Now that I am learning classes and I have done a few exercises, the exercises always requires me to use the “this” keyword when I am creating key/value pairs. Since I am not acessing any previous created value it doesn’t seem to make much sense to me to use the “this” keyword

For example :

class HospitalEmployee {


this._name = name

this._remainingVacationDays = 20



If this was an object I could simply do it , like this :

const HospitalEmployee = {

name: name,

remainingVacationDays : 20,