JSFiddle - React, Tailwind, and code Playground

by Arup Rakshit

JavaScript

var person = Object.create(null);

person.fullName = function() {
    return this.firstName + " " + this.lastName ;
}

var man = Object.create(person);
man.sex = 'male';

var arup = Object.create(man);

arup.firstName = "Arup" ;
arup.lastName = "Rakshit" ;

console.log(arup.fullName());

// another version

function Person () {};

Person.prototype.name = function () {
     return this.firstName + " " + this.lastName;
};

var Man = function () { Person.call(this); this.sex = "male" };

Man.prototype = Object.create(Person.prototype); 

var Arup = function () { Man.call(this); this.firstName = "Arup"; this.lastName = "Whatever"; };

Arup.prototype = Object.create(Man.prototype);

var arup = new Arup(); 

console.log( arup.name() === "Arup Whatever" );