JSFiddle - React, Tailwind, and code Playground
by Artem
JavaScript
var proto = (function() {
var _name = 'private';
return {
set fullName(value) {
return false;
},
get fullName(){
return _name;
},
publicVar: 'public'
};
})();
var obj = Object.create(proto);
Object.seal(obj);
var MYAPP = {
Person: function(name){
var _authorized = true;
var _cash = 3200;
this.name = name;
Object.defineProperty(this, 'cash',{
get: function(){
return _cash;
},
set: function(value){
_cash = (_authorized) ? value : _cash;
}
});
}
};
var person = new MYAPP.Person('John');
person.cash = 5000;
console.log(person.cash);