JSFiddle - React, Tailwind, and code Playground

JavaScript

function foo() {
    var a = 'private variable';
    return function bar() {
        return function foobar() {
            console.log(a);
        };
    };
}

    var getBar = foo();
    var getFooBar = getBar();
    getFooBar(); //private variable.