Reputation: 3890
How to get types.type1["color"]
from below? I mean how to write public method to get it.
Config = (function(){
var ids = {
id1: "id1",
id2: "id2",
....
}
var types = {
type1: {
"color": "red",
"size": "10"
...
},
type2: {
"color": "red",
"size": "40"
}
}
return {
getIds: function(id){
return ids[id];
}
getTypes: function(type){
return types[type];
}
}
}();
Upvotes: 0
Views: 103
Reputation: 32117
Config.getTypes("type1").color
Using:
Config = (function(){
var ids = {
id1: "id1",
id2: "id2"
};
var types = {
type1: {
"color": "red",
"size": "10"
},
type2: {
"color": "red",
"size": "40"
}
};
return {
getIds: function(id){
return ids[id];
},
getTypes: function(type){
return types[type];
}
};
})();
Upvotes: 6