JSFiddle - React, Tailwind, and code Playground
JavaScript
function myObjCreator3() {
var ret = {};
ret.x = 1;
ret.getX = function () { return ret.x; }
ret.setX = function(val) { ret.x = val; }
return ret;
}
var o = myObjCreator3();
document.write(o.x + "<BR/>");
document.write(o.getX() + "<BR/>");
o.x = 2;
document.write(o.x + "<BR/>");
document.write(o.getX() + "<BR/>");
o.setX(3);
document.write(o.x + "<BR/>");
document.write(o.getX() + "<BR/>");