Initiate a scoped function from a string in javascript
<p>Lets define a dog:</p>

<pre><code>function Dog() {}
</code></pre>

<p>Now lets define a self executing function that passes the Dog as a parameter:</p>

<pre><code>(function(dogClassName) {

    var someServerSideLogicResolvesClassName = "dogClassName";
    //Iniate class name from the server side string
})(Dog);​
</code></pre>

<p>After some googleing I found that I should use</p>

<pre><code>new window["dogClassName"]();
</code></pre>

<p>or</p>

<pre><code>new this["dogClassName"]();
</code></pre>

<p>But since it's a scoped variable it doesn't exist in the global name space (no window) and <code>this</code> is <code>undefined</code>; I have no idea how to achieve this without using some sort of evaling.  </p>
