Steps to Create Class in React
interface IEmployee {
name: string
age: number
department: string
designation: string
joiningDate: Date
}
class Employee implements IEmployee {
name: string
age: number
department: string
designation: string
joiningDate: Date
constructor(name: string, age: number, department: string, designation: string, joiningDate: Date) {
this.name = name
this.age = age
this.department = department
this.designation = designation
this.joiningDate = joiningDate
}
getDetails(): string {
return `Name: ${this.name}, Age: ${this.age}, Department: ${this.department}, Designation: ${this.designation}, JoiningDate: ${this.joiningDate}`
}
}
const employee = new Employee('Anupam', 35, 'IT', 'SE', new Date())
console.log(employee.getDetails())
Response:
![](https://i0.wp.com/tech2now.in/wp-content/uploads/2023/08/image-3.png?resize=973%2C133&ssl=1)