The constructor method initializes new instances. It receives arguments passed to new and sets up instance properties.
class Rectangle {
constructor(width, height) {
this.width = width;
this.height = height;
}
}
const rect = new Rectangle(10, 5);
console.log(rect.width); // 10