Static variables and methods in Typescript
· ☕ 2 min read
Typescript allows use of static variables and methods just like modern Javascript.
Static variables and methods are declared with a keyword static.
Static variables Static variables exist within the class context, and are not carried forward to the object of the class.
Define a static variable like so -
1 2 3 class Human { static chaos: boolean = true; } The variable value is accessible using the class.