I just discovered a way to create fake “classes” in javascript, but I wonder how you can store them and still get easy access to their functions in the IDE.
Like this:
function Map(){
this.width = 0;
this.height = 0;
this.layers = new Layers();
}
Now I have a function that goes through XML and creates several Map () objects. If I store them under one variable, I can access them simply, for example:
map1 = new Map();
map1.height = 1;
But I do not know under what name they will be saved! So I thought I could save them like this:
mapArray = {};
mapArray['map1'] = new Map();
But you cannot access the following functions: (At least the completion of the IDE code will not pick it up)
mapArray['map1'].height = 1;
Then I thought this was the best solution:
function fetch(name){
var fetch = new Map();
fetch = test[name];
}
So I could write:
fetch('test').height = 1;
But it looks like it will generate a lot of overhead continuous copies of variables like this.
- ?