JSFiddle - React, Tailwind, and code Playground
JavaScript
var API = (function() {
function API() {};
API.prototype.get = function() {
// can call private_method.
private_method();
}
// Accessible from the object created in this scope.
function private_method() {
console.log('in private method');
}
return API;
})();
// API is now reusable as a global variable.
var api = new API();
api.get();