Inside methods, this refers to the instance the method was called on.
class User {
constructor(name) {
this.name = name;
}
sayHi() {
console.log(`Hi, I'm ${this.name}`);
}
}
const alice = new User("Alice");
alice.sayHi(); // "Hi, I'm Alice"
Each instance has its own this context.