Access object child properties using a dot notation string
<p>I'm temporarily stuck with what appears to be a very simple JavaScript problem, but maybe I'm just missing the right search keywords!</p>

<p>Say we have an object</p>

<pre><code>var r = { a:1, b: {b1:11, b2: 99}};
</code></pre>

<p>There are several ways to access the 99:</p>

<pre><code>r.b.b2
r['b']['b2']
</code></pre>

<p>What I want is to be able to define a string </p>

<pre><code>var s = "b.b2";
</code></pre>

<p>and then access the 99 using </p>

<pre><code>r.s or r[s] //(which of course won't work)
</code></pre>

<p>One way is to write a function for it that splits the string on dot and maybe recursively/iteratively gets the property. But is there any simpler/more efficient way? Anything useful in any of the jQuery APIs here?</p>
