OOPS class constructor

++ Inheritance

by anoopsuda

HTML

<!--
class employee {

constructor(name, position, salary){

this.name = name;
this.position = position;
this.salary = salary;

}

getsalary(){

document.write("Salary of " + this.name + " is " + this.salary + " for the position " + this.position);

}

}

let e1 = new employee("Anoop, "Dev" , 100000);
e1.getsalary();

-->

JavaScript

const employee = function(name, position, salary){
  this.name = name;
  this.position = position;
  this.salary = salary;
};

const ex = new employee("Anoop", "FED-Developer", 115000 );
console.log(ex);



/*

  class employee  {
  constructor (name, position, salary){
  
  this.name = name;
  this.position = position;
  this.salary = salary;
  
  }  
  getsalary (){  
  document.write("Salary of " + this.name + " is " + this.salary + " for the position of " + this.position + "</br>");
  
  }
  
 }

// Inheritance

class manager extends employee {}

let e1 = new employee("Anoop", "FED-Developer", 115000 );
e1.getsalary();

let e2 = new employee("Bindu", "Medical Coder", 75000);
e2.getsalary();

let m1 = new manager("Raje", "Hr Exc", 50000);
m1.getsalary();

*/