Here’s what I need…
a for loop that iterates through an array, and for each item in the array, creates a new variable…
someObject = new Object();
for (i=0;i<theArray.length;i++){
// here's where i need help...
someObject.newProperty_i = theArray*;
}
basically, after the loop completes I want someObject to have newProperty_0, newProperty_1, … newProperty_i. I’ve tried using addProperty(), but I’m not quite clever enough to figure out what to make the getFunction.
for (i=0;i<theArray.length;i++){
theGetFunction = new Function(){
return theArray*;
};
someObject.addProperty("newProperty_"+i, theGetFunction, null);
// valid code to make a new property (read-only)
// unfortunately, it doesn't perform the way I want it to
}
As I said, it is valid code, but as it stands, all the newProperty_ variables all output whatever theArray* is (after the loop has executed), instead of outputting what theArray* WAS when I attached the property…
I’ve been banging my head against the wall here. I know there’s someone out there with a simple and elegant solution. HELP!