Check if object is defined where object name is string
<p>Is there a way to do the following without using <code>eval()</code>?</p>

<p>The following function accepts an <strong>array of strings</strong> where the strings are object names. I iterate over them to ensure that none of them are undefined. I'd like to be able to do this without using <code>eval()</code></p>

<pre><code>function hasMissingDependencies(dependencies) {
    var missingDependencies = [];

    for (var i = 0; i &lt; dependencies.length; i++) {
        if (eval('typeof ' + dependencies[i]) === 'undefined') {
            missingDependencies.push(dependencies[i]);
        }
    }

    if (missingDependencies.length &gt; 0) {
        return true;
    }

    return false;
}
</code></pre>

<p>With this, I'm able to pass something like the following and get what I want:</p>

<pre><code>alert(hasMissingDependencies(['App.FooObject', 'App.BarObject']));
</code></pre>

<p>I'd prefer to not use <code>eval()</code> but haven't found another way to check if an object is undefined when the object names are passed as strings.</p>
