flann
12 Sep 2007, 11:06 AM
What i'm trying to do is use an array or variable to call a particular function. I know that I could use a switch statement to do this, however I would like to find out if it is also possible this way.
<script>
function test1() {
alert('test1');
}
function test2() {
alert('test2');
}
myArray = new Array();
myArray[0] = "test1";
myArray[1] = "test2";
// I really thought this would work, but it didn't
myArray[0]();
</script>
<script>
function test1() {
alert('test1');
}
function test2() {
alert('test2');
}
myArray = new Array();
myArray[0] = "test1";
myArray[1] = "test2";
// I really thought this would work, but it didn't
myArray[0]();
</script>