I'd like to code something like this.
function cokeDispencer(id) {
const dict = {1:"sprite", 2:"pepcy", ...} // Some JSON. It might be bigger.
return dict[id];
}
Of course, dict[id] is much simpler way to do the same, but I want put the dict object inside of function so that no other function can access to this dict object. What I'm wondering is that the object dict is initialized everytime it called. As I know, function written in C/C++ initalize it's local variable everytime it called except static variable. If then, is there a way to initalize const variable just once like static variable C/C++?