📚 Summary of key learnings from Section 4, Part 1 of "The Complete JavaScript Course"
🔍 Topics: Abstraction, Encapsulation, Inheritance, Polymorphism, Prototypes, ES6 Classes
#
to define private fields inside ES6 classes.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
extends
and super
keywords.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);
class Animal {
makeSound() {
console.log("Animal makes a sound");
}
}
class Dog extends Animal {
makeSound() {
console.log("Bark!");
}
}
const dog = new Dog();
dog.makeSound(); // Bark!