- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 150字
- 2021-07-15 17:05:30
Classes
A class is an extensible template that is used to create objects with member variables to hold the state of the object and member functions that deal with the behavior of the object.
JavaScript only supports function-based and prototype-based inheritance to build reusable components. ECMAScript 6 provides the syntactic sugar of using classes in supporting object-oriented programming. However, not all browsers understand ES6 and we need transpilers, such as TypeScript, that compile the code down to JavaScript and target ES5, which is compatible with all browsers and platforms:
class Customer { name: string; constructor(name: string) { this.name = name; } logCustomer() { console.log('customer name is ' + this.name; } } var customer = new Customer("Rajesh Gunasundaram");
This Customer class has three members: a name property, a constructor, and a logCustomer method. The last statement outside the customer class creates an instance of the customer class using the new keyword.
- 大話PLC(輕松動漫版)
- C語言程序設計教程
- What's New in TensorFlow 2.0
- JavaScript+jQuery網頁特效設計任務驅動教程(第2版)
- C# Programming Cookbook
- Java加密與解密的藝術(第2版)
- C#程序設計(慕課版)
- Lua程序設計(第4版)
- iOS開發實戰:從入門到上架App Store(第2版) (移動開發叢書)
- The Professional ScrumMaster’s Handbook
- AMP:Building Accelerated Mobile Pages
- Python編程入門(第3版)
- 產品架構評估原理與方法
- 優化驅動的設計方法
- Beginning PHP