JSFiddle - React, Tailwind, and code Playground

JavaScript

var myObject = function () {
    var that = this;
    var foo = 1;

    function consoleIt() {
        console.log(that, foo);
    }
    return {
        bar: function () {
            consoleIt();
        }
    };
}();
myObject.bar();