Getters let you define computed properties. They look like properties but run code when accessed.
class Rectangle {
constructor(w, h) {
this.width = w;
this.height = h;
}
get area() {
return this.width * this.height;
}
}
const r = new Rectangle(4, 5);
console.log(r.area); // 20 (no parentheses)