javascript eval - how to assign value to object property?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4244896/dynamic-object-property-name">Dynamic object property name</a>  </p>
</blockquote>



<p>I have an object like this</p>

<pre><code>var localAppConfig = {
    wallet:0,
    paySomeone:0,
    payBills:0,
    accounts:0,
    moveMoney:0,
    alerts:0,
    offers:0,
    checkIn:0
};
</code></pre>

<p>I want to set value 1 for particular elements within this <code>localAppConfig</code></p>

<p>Which element needs to be set is retrieved from the <code>json</code> - which arrives from the server.</p>

<p>say, I want to set value = 1 for wallet, paySomeone, payBills, alerts, offers, checkIn</p>

<p>These are retirved from the <code>json</code> like</p>

<pre><code>for(var i=0;i&lt;len;i++){
        var name = list[i].handle;
        var accessor = eval('localAppConfig.'+name);
        eval('localAppConfig.'+name)=1;
    }
</code></pre>

<p><code>var name</code> contains name of the element and I am able to access its value correctly,</p>

<p>How can I set the value using javascript?</p>

<p>I tried <code>accessor=1</code> but its not working.</p>

<p>Thanks :)</p>
