Maybe a closure is my solution? Not exactly sure how to pull it off though.
The code is set up like so:
var globalVar = '';
var globalVar2 = '';
function func()
{
if (condition)
func2(globalVar)
else
func2(globalVar2)
}
In func2() I cache some HTML in a main container into the appropriate global variable that I pass to it. Basically I have a main container that holds different pages depending on what tab they choose. For performance I want to cache the page into global vars so I need to know what tab is active to figure out which global var to assign the HTML to.
as globals are just properties of the
windowobject in javascript, just pass"globalVar"or"globalVar2"and assign it usingwindow[myvar] = ...