Answers for "a class member cannot have the 'const' keyword angular 8"

2

A class member cannot have the 'const' keyword angular

//Change this...
const myVar = 123;

//To this...
readonly myVar = 123;
Posted by: Guest on May-24-2021
1

A class member cannot have the 'const' keyword.

class MyClass {
    readonly myReadOnlyProperty = 1;

    myMethod() {
        console.log(this.myReadOnlyProperty);
        this.myReadOnlyProperty = 5; // error, readonly
    }
}

new MyClass().myReadOnlyProperty = 5; // error, readonly
Posted by: Guest on May-12-2021

Code answers related to "a class member cannot have the 'const' keyword angular 8"

Code answers related to "Javascript"

Browse Popular Code Answers by Language