Inheritance and Implements
A class can extend another class and implement an interface, which is a promise to have certain members.
Exampletypescript
constructor(public name: string) is a shortcut that declares and assigns the property. If a class forgets to deliver the promise:
Exampletypescript
Quick check
What does `implements Speaker` require?
Your turn: write the code
Make Square implement Shape so that area() returns the side squared. Print the area of a square with side 5.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.