Dynamically retrieving variable from chained objects
<p>I'm having trouble figuring out how to access a variable in a multilevel deep object using a function like</p>

<pre><code>getLanguageVariable("form.passwordSwitch.disabled");
</code></pre>

<p>and the following object as sample</p>

<pre><code>var language = {
    "de": {
        "form": {
            "passwordSwitch": {
                "enabled": "Der Klartext-Modus ist aus. Aktivieren?",
                "disabled": "Der Klartext-Modus ist an. Deaktivieren?"
            }
        }
    }
}
</code></pre>

<p>Tried to split the string at the dot character, then creating a string representation of</p>

<pre><code>language["de"]["form"]["passwordSwitch"]["enabled"]
</code></pre>

<p>which is used to access objects and it's properties. I used this code:</p>

<pre><code>var stack = variableIdentifier.split(".");
var reference = "";

for (i = 0; i &lt; stack.length; i++) {
    if (i == 0) reference += stack[i];
    else reference += "[\"" + stack[i] + "\"]";
}
</code></pre>

<p>Any clues how to dynamically access the properites of an object, given you don't know how deep it is?</p>
