Classes in typescript

If we want Car to have different drive, simply redefine:

Modifiers

public, private, protected – Restrict access

public – can be called any where, any time
private: can be only called by other methods in THIS class.
protected – called by other methods in THIS class, or by other methods in child classes.

by default, it’s public.

If we’re ever over-riding an interface, we cannot change modifier:

If its protected, we can can access in child class.

shortcut

Also note that if we change it to private, then child classes can’t access it anymore.

In order to be made accessible in child class, we can change it back to public or protected.