JSFiddle - React, Tailwind, and code Playground
by dcdruck
HTML
<html><head></head><body></body></html>
JavaScript
(function(window,undefined){
var document = window.document || undefined;
var myString = 'String produced by custom namespace';
var myString2 = 'String #2 privately accessibly to myObject';
var myObject = window.myObject = {
a: 0,
b: 1
};
myObject.testMyWindow = function() {
console.log(myString );
var el = document.createElement('div');
el.innerHTML=myString;
document.body.appendChild(el);
};
myObject.makeNewFunction = function() {
return function () {
return function() {
console.log(myString2);
var el = document.createElement('div');
el.innerHTML=myString2 + '<br>' + myString2;
document.body.appendChild(el);
}
};
};
})(window);
var el=document.createElement('div');
el.innerHTML = 'Begin';
document.body.appendChild(el);
try {
console.log(myObject);
var el = document.createElement('div');
el.innerHTML=myObject.toString();
document.body.appendChild(el);
myObject.testMyWindow();
(myObject.makeNewFunction())()();
} catch (ex) {
console.log('Exception: ' + ex);
}