JSFiddle - React, Tailwind, and code Playground
by f0t0n
JavaScript
var Employee = function(name) {
this.name = name;
return this;
};
Employee.prototype = {
doWork: function() {
console.log('%s is doing some abstract work', this.name);
}
};
var Driver = function(name) {
return Employee.call(this, name);
};
Driver.prototype = Object.create(Employee.prototype, {
doWork: {
value: function() {
console.log('%s is driving a car', this.name);
}
},
fixEngine: {
value: function() {
console.log('%s is fixing an engine', this.name);
}
}
});
var employee = new Employee('Jim');
var driver = new Driver('Bill');
employee.doWork(); // Jim is doing some abstract work
driver.doWork(); // Bill is driving a car
driver.fixEngine(); // Bill is fixing an engine