I am looking to create an Object that will encompass all the immutable properties which cannot be altered from outside sources,
for instance :
var Constants = (function(){
this.server_port = 8888;
this.server_name = '127.0.0.1';
return ({
getConstantValue : function(constantName){
/*
This function will retrieve the property based on the
name of the constant provided
*/
}
});
}());
Therefore, if anyone were to input
Constants.getConstantValue('server_port');//will yield 8888;
Constants.getConstantValue('server_name');//will yield 127.0.0.1;
How can this be accomplished without exposing the properties externally? I would appreciate any insight or suggestions. Thank you in advance.