this keyword in Class Javascript
this keyword in Class Javascript
class user {
constructor(n) {
this.name = n;
}
getName() {
console.log(this.name); // this points to variables in constructor of the class
}
}
const User = new user("Chaitanya");
User.getName(); // Chaitanya