title: JavaScript acrobatics: How to assign an object literal to an eval-uated property?
body: <p><a href="https://github.com/jamiemthomas/jquery-datalink/blob/master/jquery.tmpl.datalink.js" rel="nofollow">Original code</a> from <a href="https://github.com/jamiemthomas" rel="nofollow">JamieMThomas</a>, a (really good guy who is trying to combine Microsoft JQuery Templates and Linking) :</p>
  
  <pre><code>mapping[binding.field] = {
      convert: function (value, source, target) {
          if (binding.converter &amp;&amp; binding.converter.convert) {
              value = binding.converter.convert(value, source, target)
                  if (value === undefined)
                      return;
          }
          $(target).attr(attrName, value);
      }
  };
  </code></pre>
  
  <p>I am trying to hack it to allow <code>binding.field</code> to work with a string like <code>"LPC[0].itemid"</code> (literally a string).  I am using eval as a terrible choice, but it's the fastest thing I can do (and will rewrite it later).  I originally tried assigning the content to the eval('') itself, but it didn't allow me.</p>
  
  <pre><code>eval('(mapping.' + binding.field + ')') =
      { // rest is the same
      convert: function (value, source, target) {
          if (binding.converter &amp;&amp; binding.converter.convert) {
              value = binding.converter.convert(value, source, target)
                  if (value === undefined)
                      return;
          }
          $(target).attr(attrName, value);
      }
  };
  </code></pre>
  
  <p>Obviously an invalid assignment on the left hand side.  How could I accomplish this?</p>