I'm trying to create a new object to use as an associative array automatically.
I can programmaticall y create new variables like this:
And I can create a new object like this:
but I don't know how to create for example
I want to do this because I'm going to make a cgi call to a C program which includes a date range parameter and various other things. Once I get a large array back I'm going to calculate median, standard deviation, spikes, etc. I want to save the array and those calculations in an object, since I'll potentially get 40 different results back. If I save these properties, then I can cache the calculations and cgi query results, so I don't have to make the same request/calculations twice.
So, I'd like the object name to be something close to my cgi query string. Then before I make the query again, I can see if I already have the object. If I do, I have the data, and the calculations.
When a new date range is selected, though, I would like to be able to delete all the cached objects so they aren't eating browser memory.
Any pointers?
I can do this with a whole slew of automatically created variables, but it would be nicer and more logical to do via objects.
I can programmaticall y create new variables like this:
Code:
for (var i; i < 10; i++) {
window["foo" + i];
window["foo" + i] = "moo" + i;
}
// now I have foo0,foo1, foo2, foo3... foo9
Code:
var myObject = new Object();
Code:
for (...) {
var myObject + i = new Object();
}
So, I'd like the object name to be something close to my cgi query string. Then before I make the query again, I can see if I already have the object. If I do, I have the data, and the calculations.
When a new date range is selected, though, I would like to be able to delete all the cached objects so they aren't eating browser memory.
Any pointers?
I can do this with a whole slew of automatically created variables, but it would be nicer and more logical to do via objects.
Comment