Object oriented programming

a.k.a. OOP

An imperative programming paradigm that uses classes for abstraction, encapsulation, and polymorphism.


Example

class Rectangle {
  constructor(width, height) {
    this.width = width;
    this.height = height;
  }

  getArea() {
    return this.width * this.height;
  }
}

class Square extends Rectangle {
  constructor(size) {
    super(size, size);
  }
}

const rect = new Rectangle(5, 2);
rect.getArea();
10
const square = new Square(6);
square.getArea();
36

External Resources