educative.io

Educative

Arguments provided in the instance is incorrect

Devteadlead required 2 argument in it’s coming constructor but in the example 3 arguments provided. Can you explain why is it so?

Hey @siddharth2

class DevTeamLead extends Employee{
    constructor(name,position){
        super(name,position)
        this.teamMembers = []
    }
    addMember(employee){
        this.teamMembers.push(employee)
    }

Inside constructor super keyword is used which immediately invokes its parents constructor. Since its parent class is taking 3 arguments therefore it will also take three arguments as when this function will be called, the constructor of if its parent class will be invoked due to super.
For any further query feel free to ask.

Happy learning,