JSFiddle - React, Tailwind, and code Playground
by seong gyun jeon
JavaScript
var Class = (function(){
// private valiable
var privates = {
names: {}
};
var _class = function(){
this.id = 'mohwa';
this.key = String(new Date().getTime());
return this;
}
_class.fn = _class.prototype = {
getName: function(){
return privates['names'[this.key]];
},
setName: function(name){
privates['names'[this.key]] = name;
return this;
}
}
return _class;
})();
alert(new Class().setName('전성균').getName());
alert(new Class().names);