JSFiddle - React, Tailwind, and code Playground

by smacky311

JavaScript

function M() {
    var myVar = "blah";
    console.log(myVar);
}

function N() {    
    console.log(myVar);
}

//M();
//N();
var myObject = myPowerConstructor("e");
myObject.priv();

function myPowerConstructor(x) {
    var that = otherMaker(x);//invokes f()    
    var secret = f(x);
    that.priv = function() {
        console.log('priv called');
    };//append new object to priv
    return that;//priv is a new object with access to secret via Closure
}

function f(myVariable2) {
}

function otherMaker(myVariable) {    
    var priv = {};    
    console.log('other maker execution');
    return priv;
}