Google News
logo
Angular - Interview Questions
Write some code for a basic class in TypeScript with a constructor and a method.
Here‘s a simple class that is created with a greeting message which can be retrieved with the greet() function.
class Greeter {
  greeting: string;
     constructor(message: string) {
        this.greeting = message;
      }
       greet() {
         return "Hello, " + this.greeting;
       }
     }

  let greeter = new Greeter("world");
Advertisement