- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 75字
- 2021-07-15 17:05:32
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.
推薦閱讀
- CockroachDB權(quán)威指南
- Java EE 6 企業(yè)級應用開發(fā)教程
- PHP程序設(shè)計(慕課版)
- C/C++算法從菜鳥到達人
- JMeter 性能測試實戰(zhàn)(第2版)
- 利用Python進行數(shù)據(jù)分析(原書第3版)
- Go并發(fā)編程實戰(zhàn)
- Node.js Design Patterns
- Mastering React
- 零基礎(chǔ)C#學習筆記
- 邊玩邊學Scratch3.0少兒趣味編程
- OpenCV 3.0 Computer Vision with Java
- DevOps 精要:業(yè)務視角
- Elasticsearch搜索引擎構(gòu)建入門與實戰(zhàn)
- JBoss AS 7 Development