Problem Statement
Which access modifiers exist in TS classes?
Explanation
public (default) is visible everywhere, private is only inside the class, protected is inside the class and its subclasses, readonly prevents reassignment of that property after construction.
Code Solution
SolutionRead Only
class User {
public id: string;
protected role: string = 'user';
private secret = 'shh';
readonly createdAt = new Date();
constructor(id: string){ this.id = id; }
}