class Settings {
//type constant (readonly field)
static get maxConnections() {
return 3;
}
}
let max = Settings.maxConnections;
//max is 3
console.log(`max is ${max}`);
// *** up to ES6 ***
function Config() {}
//type fields
Config.Host = "10.0.0.1";
Config.Port = 0;
//type method
Config.getConnection = function() {
return Config.Host + ":" + Config.Port;
}
Config.Port = 52;
var connection = Config.getConnection();
//connection is "10.0.0.1:52"
console.log(`connection is ${connection}`);
Config.Host = "10.0.0.3";
connection = Config.getConnection();
//connection is "10.0.0.3:52"
console.log(`connection is ${connection}`);