- 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.
- 極簡算法史:從數學到機器的故事
- Mastering Entity Framework Core 2.0
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- AngularJS Web Application Development Blueprints
- C語言程序設計
- Blockly創意趣味編程
- 精通API架構:設計、運維與演進
- Raspberry Pi 2 Server Essentials
- 單片機應用技術
- Full-Stack Vue.js 2 and Laravel 5
- 劍指Java:核心原理與應用實踐
- C語言開發基礎教程(Dev-C++)(第2版)
- C語言程序設計
- 網絡數據采集技術:Java網絡爬蟲實戰
- Python Web自動化測試設計與實現