Inheritance - Javascript
function Employee(first, last) {
this.firstname = first
this.lastname = last
}
Employee.prototype.fullname = function() {
return this.firstname + " " + this.lastname
}
var firstemp = new Employee("Mukta", "Dadariya")
console.log(firstemp.fullname())
function Permanent(salary) {
this.empsalary = salary
}
Permanent.prototype = firstemp
var firstempsalary = new Permanent(500000)
console.log(firstempsalary.fullname())
this.firstname = first
this.lastname = last
}
Employee.prototype.fullname = function() {
return this.firstname + " " + this.lastname
}
var firstemp = new Employee("Mukta", "Dadariya")
console.log(firstemp.fullname())
function Permanent(salary) {
this.empsalary = salary
}
Permanent.prototype = firstemp
var firstempsalary = new Permanent(500000)
console.log(firstempsalary.fullname())
Comments
Post a Comment