- 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.
- PostgreSQL Cookbook
- Python自然語言處理(微課版)
- HTML5入門經典
- Android Native Development Kit Cookbook
- SAP BusinessObjects Dashboards 4.1 Cookbook
- Python數據結構與算法(視頻教學版)
- ASP.NET Core 2 Fundamentals
- HTML5秘籍(第2版)
- Mastering ASP.NET Core 2.0
- 你真的會寫代碼嗎
- Java程序設計實用教程(第2版)
- 程序員面試金典(第6版)
- Learning ROS for Robotics Programming
- Visual FoxPro數據庫程序設計
- Xamarin Mobile Application Development for Android(Second Edition)