JSFiddle - React, Tailwind, and code Playground
JavaScript
function MyClass(){
var foo = 'bar'; // private because of "scope"
this.setfoo = function(f) {
foo = f;
}
this.getfoo = function() {
return foo;
}
}
var instance = new MyClass();
console.log(instance.foo); // undefined
console.log(instance.getfoo()); // bar
instance.setfoo('a');
console.log(instance.getfoo()); // a