JSFiddle - React, Tailwind, and code Playground
JavaScript
var Person = function(firstName, lastName)
{
this.lastName = lastName;
this.firstName = firstName;
};
Object.defineProperties(Person.prototype, {
sayHi: {
value: function() {
return "Hi my name is " + this.firstName;
}
},
fullName: {
get: function() {
return this.firstName + " " + this.lastName;
}
}
});
var Employee = function(firstName, lastName, position) {
Person.call(this, firstName, lastName);
this.position = position;
};
Employee.prototype = Person.prototype;
var john= new Employee("John", "Doe", "Dev");
var jane = new Person("Jane", "Doe");
Employee.prototype.work = function() { document.write(this.fullName +" is doing some "+ this.position +" stuff<br/>"); };
john.work();
jane.work();