class Klazz {
constructor(
public pubField: string,
protected prtField: string,
private prvField: string,
localVar: string
) {
console.log('Other operations...');
// all variables are accessible here
}
someMethod() {
console.log(
this.pubField,
this.prtField,
this.prvField
);
// localVar is only accessible within the constructor()
}
}
pubFieldis accessible from any placeprtFieldis only accessible from the class itself and classes that extends the classprvFieldis only accessible from the class itselflocalVaris only accessible withinconstructor()in the class