官术网_书友最值得收藏!

Static properties

These 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 called bonusPercentage that is accessed using the class name Customer in the calculateBonus method. This bonusPercentage property is not instance-specific.

主站蜘蛛池模板: 潜江市| 台东县| 临海市| 垦利县| 墨脱县| 怀远县| 舒城县| 遂川县| 河曲县| 来宾市| 平南县| 团风县| 永丰县| 池州市| 赣榆县| 理塘县| 兴仁县| 赤城县| 崇文区| 米脂县| 墨脱县| 谷城县| 绩溪县| 依兰县| 桃园市| 绵竹市| 宜章县| 神池县| 湘潭市| 盱眙县| 加查县| 淅川县| 新河县| 崇左市| 法库县| 乐至县| 巴彦淖尔市| 云梦县| 响水县| 宜良县| 临汾市|