From the course: TypeScript: Object-Oriented Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Implementing classes in TypeScript

Implementing classes in TypeScript

From the course: TypeScript: Object-Oriented Programming

Start my 1-month free trial

Implementing classes in TypeScript

- [Instructor] In previous lectures, we talked about how extends works with our parent or base class in our child class. Now we're going to talk about implements and how it differs. If we were to change extends here in our Dog derived or child class to implements, a couple things happen that are more contextual than actually code base. Code base-wise, we have to redefine the properties and the methods associated with our animal class to not necessarily be a direct child but to actually match the same shape. We'll be able to use them interchangeably like we would from a parent to child but really when going from extends to implements for matching the shape of said parent base class. In our case so it'll be age, number, legs, number, and then name, string. There's also a bit of a conversation going on from a contextual standpoint of one being better than the other from a readability standpoint. Before when we were extending, if…

Contents