Javascript - how to use variables to replace the existing code at run time : <p>I have the below code and i want to replace the code at run time depending on a variable value, how do i achieve this using javascript. Also please ignore the FormA , animate etc as they are used by kony mobile. </p>

<pre><code>//desired out put inside the run time code. 
    FormA.ItemFlexContainer0.animate

    //index has a value of 0 for now. 
    var index = 0;
    var ItemFlexContainerString = "ItemFlexContainer"+index;
    FormA.ItemFlexContainerString.animate

    Error :- Type Error null is not an object 
</code></pre>

<p>Since ItemFlexContainerString doesnt exist it will throw the error. </p>
