JSFiddle - React, Tailwind, and code Playground

by aslancods

HTML

<input type="button" onclick="toProve()" value="clickme" />

JavaScript

var Foo = function() {
    var creator = this;
    this.name= "foo";
    this.bar = {
        name: 'bar',
        callMe: function(){ 
            alert(this.name); 
        },
        callPar: function(){
            alert( creator.name )
        }
    }

} 

function toProve() {
    var callThem = new Foo();

    callThem.bar.callMe();
    callThem.bar.callPar();
}