I need to selectively run several functions depending on various situations. I have a basic object like this:
object = {
whatever : {
objects : null
},
something : {
objects : // some object
}
};
I need to iterate through the object values and if objects is not null, I need to run a specific function. If whatever.objects is not null, I need to run whateverFunction();. If something.objects is not null, I need to run somethingFunction();.
for( i in object )
{
if ( object[i].objects )
// run a certain function
}
What is the best way to run these artibtrarily named functions based off of the values in the object? I could store the name of the "function-to-be-run" in the object and eval() it, but I'd like to try to avoid evaling.
Would it make more sense to create an class object each with it's own function to be run, and if so, how would I do this?