O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Static properties

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required