Interface in Typescript Example !
export interface emp{
fname:string;
lname:string;
display();
}
-----------------------------------------------------------------------------------------
import { emp } from "./interface";
export class employee implements emp{
fname: string;
lname: string;
salary:number;
constructor(f:string,l:string,sal:number){
this.fname=f;
this.lname=l;
this.salary=sal;
}
display() {
console.log(`
---------------Employee Details-------------------------
First Name::${this.fname}
Last Name::${this.lname}
salary::${this.salary}
`)
}
}
Comments
Post a Comment