Notes on Javascript and Object Oriented Programming

Interface

An interface in typescript allows us to define the stucture/shape/syantax of a class that implements it. This also means that a class that implements an interface is contractually bound to implment all its members.

interface Person {
  firstName: string;
  lastName: string;
  getFullName(): string;
}

// Implementation
class Foo implements Person {
  firstName: string;
  lastName: string;
  getFullName(): string {
    return `My name is ${this.firstName} + ${this.lastName}`;
  }
}

Duck Typing

Private vs Public members

All Rights Reserved | © 2020 | Made by Omar with ❤️ and