December 2016
Intermediate to advanced
841 pages
17h
English
We should already be familiar with the basics about TypeScript classes, as we have declared some of them in previous chapters. So we will now look at some details and OOP concepts through examples. Let's start by declaring a simple class:
class Person {
public name : string;
public surname : string;
public email : string;
constructor(name : string, surname : string, email : string){
this.email = email;
this.name = name;
this.surname = surname;
}
greet() {
alert("Hi!");
}
}
var me : Person = new Person("Remo", "Jansen", "remo.jansen@wolksoftware.com");We use classes to represent the type of an object or entity. A
class is composed of a name, attributes, and methods. The class in the preceding example is named Person and contains three attributes ...
Read now
Unlock full access