Classes implementing interfaces

In TypeScript, a class can implement an interface by using the implements keyword. Here's an example of defining an interface and implementing it in a class:

interface IPerson { 
    FirstName: string; 
    LastName: string; 
 
    getDetails(): string; 
} 
 
class Employee implements IPerson { 
    EMP_ID: string; 
 
    FirstName: string; 
    LastName: string; 
 
    getDetails(): string { // method implementation 
        return `${this.FirstName} ${this.LastName} -  
${this.EMP_ID}`; 
    } 
} 
 
class Customer implements IPerson { 
    CUST_ID: string; 
 
    FirstName: string; 
    LastName: string; 
 
    getDetails(): string { // method implementation 
        return `${this.FirstName} ${this.LastName} -  
${this.CUST_ID}`; 
    } 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.72