How to turn this JavaScript string "myArray[0].myPrice" in to a reference to myPrice?
<p>If I have a string of <code>"myArray[0].myPrice"</code>, how do I turn this in to a reference to <code>myPrice</code>?</p>

<p>This is the code context:</p>

<pre><code>binding.value = convert(binding.data[binding.field], 
                        binding.converter, binding.data, elem); 
</code></pre>

<p><code>binding.field</code> is what contains "myArray[0].myPrice".</p>

<p><code>binding.data</code> has a reference to the hierarchical object which has an Array property of myArray, and the first element is an object with a property of myPrice.</p>

<p>EDIT: based on the answers, this worked:</p>

<pre><code>binding.value = convert(eval('(binding.data.' + binding.field + ')'), 
              binding.converter, binding.data, elem);
</code></pre>

<p>Is it good to use eval like this?  I thought eval was going away in newer JavaScript?</p>
