I am trying something new: emulating static variables in JavaScript. Even though JavaScript does not have static variables like some languages (e.g., C++), I have done some searches and it seems there are a few ways to provide the same behaviour.

Here’s a sample of basic code, similar to what I am trying to do.

```
function calculate_ABCDE(inPar1, inPar2, inPar3){
var dummy1, dummy2, dummy3;
var endResult1, endResult2;
dummy1 = Math.cosh(inPar1) + Math.tanh(inPar1);
dummy2 = cos(Math.PI /180.0 * inPar2);
dummy3 = inPar3 + dummy1 + dummy2;
// MANY MORE CALCULATIONS
endResult1 = ...
endResult2 = ...
return;
}
```

Basically, dummy1 and dummy2 are calculated the first time the function is called, and these values are used in MANY MORE CALCULATIONS–but the values of dummy1 and dummy2 do not change any other time the function is called. Since these variables are the results of trigonometric and hyperbolic trigonometric calculations, they are quite expensive to calculate, and I would like to avoid re-calculating them. Hence my interest in static variables.

I have read on some pages that Immediately Invoked Function Expressions (IIFEs) are one way to go, but I am having troubles wrapping my brain around this technique. To me, the name connotes a fancy function, which means re-calculating the values, which is what I am trying to avoid. Am I mistaken? If not, how do I go about this? Any suggestions and help much appreciated.