JSFiddle - React, Tailwind, and code Playground

by shriek

JavaScript

function Parent() {
    var self = this;
    self.firstName;
    self.lastName;
}
Parent.prototype.getFullName = function (callback) {
    // used alert for the sake of simplicity
    alert("Callback: " + callback());
    return this.firstName + ' ' + this.lastName;
}
Parent.prototype.flipName = function () {
    return this.lastName + ' ' + this.firstName;
}
Parent.prototype.setFirstName = function (name) {
    this.firstName = name;
}

Parent.prototype.setLastName = function (last) {
    this.lastName = last;
}

var johny = new Parent();
johny.setFirstName("Johny");
johny.setLastName("Bravo");
// used alert for the sake of simplicity
alert("FullName: " + johny.getFullName(johny.flipName.bind(johny)));