JSFiddle - React, Tailwind, and code Playground

by spechackers

JavaScript

function Profile(u) {
    this.user = u;
    this.getUser = function () {
        return this.user;
    };
}
function Profile2(u) {
    this.user = u;
    this.getUser = (function () {
        return this.user;
    });
}
function Profile3(u) {
    this.user = u;
    this.getUser = (function () {
        return this.user;
    });
}

var x = new Profile('guest');
var x2 = new Profile2('guest');
var x3 = new Profile3('guest');

console.log(x.getUser.apply({
    user: 'Vinoth'
})); // Vinoth
console.log(x2.getUser.call({
    user: 'Vijay'
})); // babu
console.log(x3.getUser.bind(x3).call({
    user: 'Shankar'
})); // Guest