TypeScript · Junior · Question 40 of 75
What does implements do in a class?
- ✓Correct answer: Checks that the class matches the interface; it doesn't inherit anything
- 2Inherits the interface's method and property implementations into the class
- 3Creates an instance of the interface accessible via
this
Explanation
class Cat implements Animal - the compiler checks that the class has all the members of Animal. You have to write the implementation yourself, unlike extends for classes. Interfaces don't exist at runtime.