0 votes
in TypeScript - JavaScript's Superset by
What do you understand by classes in Typescript? List some features of classes.

1 Answer

0 votes
by

We know, TypeScript is a type of Object-Oriented JavaScript language and supports OOPs programming features like classes, interfaces, etc. Like Java, classes are the fundamental entities which are used to create reusable components. It is a group of objects which have common properties. A class is a template or blueprint for creating objects. It is a logical entity. The "class" keyword is used to declare a class in Typescript.

Example:

class Student {    

    studCode: number;    

    studName: string;    

    constructor(code: number, name: string) {    

            this.studName = name;    

            this.studCode = code;    

    }    

    getGrade() : string {    

        return "A+" ;    

    }    

}    

Features of a class are-

  • Inheritance
  • Encapsulation
  • Polymorphism
  • Abstraction

Related questions

0 votes
asked Mar 23, 2022 in TypeScript - JavaScript's Superset by sharadyadav1986
0 votes
asked Mar 22, 2022 in TypeScript - JavaScript's Superset by sharadyadav1986
...