ts define class code example
Example 1: ts class
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}}
let greeter = new Greeter("world");Try
Example 2: classes in ts
class Greeter { greeting: string;
constructor(message: string) { this.greeting = message; }
greet() { return "Hello, " + this.greeting; }}
let greeter = new Greeter("world");Try