class and its inheritance

 class Employee{

constructor(name,age,college){

this.name=name;

this.age=age

this.college=college

}

showname(){

        return 'hello i am '+this.name

}

add(a,b){

return a+b

}


}


let e1= new Employee("rajiv",20,"ACEM");

console.log(e1.showname())

console.log(e1.college)

console.log(e1.add(2,3))




here the methods inside constructor is object but other functions outside the constructor inside the class are prototye

Comments