How to pass a reference to a string in JavaScript?

Posted by ijjo on Stack Overflow See other posts from Stack Overflow or by ijjo
Published on 2010-05-18T17:36:05Z Indexed on 2010/05/18 17:50 UTC
Read the original article Hit count: 187

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about PASS