JSFiddle - React, Tailwind, and code Playground
by Jake Barrow
JavaScript
var myMath = (function MyMath() {
this.Pi = 3.14;
this.R = 0;
var MyPrivateProp1 = 15;
this.MyCalcMethod = function() {
return R * MyPrivateProp1;
};
return this;
})();
myMath.R = 5;
var x = myMath.Pi * myMath.R;
console.log(myMath.Pi);
console.log(myMath.R);
console.log(myMath.MyPrivateProp1); //This is returned as Undefined because it is a Private Variable to the Object.
console.log(myMath.MyCalcMethod());
console.log(x);