TypeScript · Middle · Question 13 of 75

How does protected differ from private in TypeScript classes?

Explanation

public (the default) is accessible everywhere, protected in the class and its subclasses, private only in the declaring class. All three are compiler checks; for real runtime privacy there's #field.

Further reading

Problem with a question

TypeScript · Middle · question 13

Test yourself

Take the TypeScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz