JSFiddle - React, Tailwind, and code Playground

by Givi Kesanashvili

JavaScript

function Base (firstName, lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
}

function Derived (firstName, lastName, age) {
    Base.apply(this, arguments);
    this.age = age;
}

Derived.prototype = Object.create(Base.prototype, {
    constructor: {
        value : Derived
    }
});

var person = new Derived("John", "Doe", 25);

console.log(person instanceof Derived);
console.log(person instanceof Base);

console.log("My name is " + person.firstName + " " + person.lastName + " and I have " + person.age + " years old.");