Implements vs extends

  • extends means:

The new class is a child. It gets benefits coming with inheritance. It has all properties, methods as its parent. It can override some of these and implement new, but the parent stuff is already included.

  • implements means:

The new class can be treated as the same "shape", while it is not a child. It could be passed to any method where the Person is required, regardless of having different parent than Person

class Person {
  name: string;
  age: number;
}
class Child extends Person {}
class Man implements Person {}
  • When a subclass extends a class, it allows the subclass to inherit (reuse) and override code defined in the supertype.

  • When a class implements an interface, it allows an object created from the class to be used in any context that expects a value of the interface.

Last updated