📚 Summary of key learnings from Section 4, Part 1 of "The Complete JavaScript Course"

🔍 Topics: Abstraction, Encapsulation, Inheritance, Polymorphism, Prototypes, ES6 Classes


1️⃣ 🎭 Abstraction


2️⃣ 🔐 Encapsulation

class BankAccount {
  #balance;
  constructor(owner, balance) {
    this.owner = owner;
    this.#balance = balance;
  }
  getBalance() {
    return this.#balance;
  }
}
const acc = new BankAccount("John", 1000);
console.log(acc.getBalance()); // 1000

3️⃣ 🧬 Inheritance

class Person {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }
}
class Student extends Person {
  constructor(name, age, course) {
    super(name, age);
    this.course = course;
  }
}
const student1 = new Student("Mike", 20, "Computer Science");
console.log(student1);

4️⃣ 🔁 Polymorphism

class Animal {
  makeSound() {
    console.log("Animal makes a sound");
  }
}
class Dog extends Animal {
  makeSound() {
    console.log("Bark!");
  }
}
const dog = new Dog();
dog.makeSound(); // Bark!