July 2017
Intermediate to advanced
454 pages
10h 1m
English
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 ...Read now
Unlock full access