These type of properties are not instance specific and are accessed by a class name instead of using the this keyword:
class Customer {
static bonusPercentage = 20;
constructor(public salary: number) { }
calculateBonus() {
return this.salary * Customer.bonusPercentage/100;
}
}
var customer = new Customer(10000);
var bonus = customer.calculateBonus();
Here, we declared a static variable, bonusPercentage, accessed using the Customer class name in the calculateBonus method. The bonusPercentage property is not instance specific.