Javascript, value types as reference
<p>I've some scenarios where i need to pass value type as reference without changed the processing function.</p>

<ol>
<li><p>Example Numeric Types (var limit)</p>

<pre><code>var limit = 0; // Need to be the reference type
var multiCallback = new MultiCallback(limit, function(){});
for (element in myObject)
{
    limit++;
    element.DoSomething(multiCallback.callback);
}

function MultiCallback(limit, func)
{
    var calls = 0;

    function callback()
    {
        if (++calls == limit)
        {
           func();
        }
    }

    return {
       callback : callback
    }
}
</code></pre></li>
<li><p>Examble Function Types</p>

<pre><code>var resizeCallback = function(){};
$(window).resize(resizeCallback);

function showPage()
{
   resizeCallback = resizePage();
}

function showLoader()
{
   resizeCallback = resizeLoader();
}
</code></pre></li>
</ol>

<p>is there a solution</p>
