var CONFIG = (function() {
var privates = {
'MY_CONST': '1',
'ANOTHER_CONST': '2'
};
return {
get: function(name) { return privates[name]; }
};
})();
alert('MY_CONST: ' + CONFIG.get('MY_CONST')); // 1
CONFIG.MY_CONST = '2';
alert('MY_CONST: ' + CONFIG.get('MY_CONST')); // 1
CONFIG.privates.MY_CONST = '2'; // error
alert('MY_CONST: ' + CONFIG.get('MY_CONST')); // 1
I would like to have feedback from my blog readers. Your valuable feedback, question,
or comments about this article are always welcome.
I would like to have feedback from my blog readers. Your valuable feedback, question,
or comments about this article are always welcome.
No comments:
Post a Comment