Convert string to an attribute for a nested object in javascript
<p>I am trying to access a string <code>"key1.key2"</code> as properties of an object.
For example :</p>

<pre><code>var obj = { key1 : {key2 : "value1", key3 : "value2"}};
var attr_string = "key1.key2";
</code></pre>

<p>The variable <code>attr_string</code> is a string of attributes in a nested object joined by <code>"."</code>. It can be of any depth like <code>"key1.key2.key3.key4..."</code></p>

<p>I want something like <code>obj.attr_string</code> to give the value of <code>obj["key1"]["key2"]</code> that is <code>"value1"</code></p>

<p>How to achieve this?</p>
