a class member cannot have the 27const 27 keyword angular

Solutions on MaxInterview for a class member cannot have the 27const 27 keyword angular by the best coders in the world

showing results for - "a class member cannot have the 27const 27 keyword angular"
Simona
19 Aug 2017
1//Change this...
2const myVar = 123;
3
4//To this...
5readonly myVar = 123;
Julieta
08 Jan 2021
1class MyClass {
2    readonly myReadOnlyProperty = 1;
3
4    myMethod() {
5        console.log(this.myReadOnlyProperty);
6        this.myReadOnlyProperty = 5; // error, readonly
7    }
8}
9
10new MyClass().myReadOnlyProperty = 5; // error, readonly
11