title: Creating object with dynamic keys
body: <p>First off, I'm using <a href="https://github.com/MatthewMueller/cheerio" rel="noreferrer">Cheerio</a> for some DOM access and parsing with Node.js. Good times.</p>
  
  <p>Heres the situation: </p>
  
  <p>I have a function that I need to create an object. That object uses variables for both its keys and values, and then return that single object. Example:</p>
  
  <pre><code>stuff = function (thing, callback) {
    var inputs  = $('div.quantity &gt; input').map(function(){
      var key   = this.attr('name')
       ,  value = this.attr('value');
  
       return { key : value }
    }) 
  
    callback(null, inputs);
  }
  </code></pre>
  
  <p>It outputs this: </p>
  
  <pre><code>[ { key: '1' }, { key: '1' } ]
  </code></pre>
  
  <p>(<code>.map()</code> returns an array of objects fyi)</p>
  
  <p>I need <code>key</code> to actually be the string from <code>this.attr('name')</code>.</p>
  
  <p>Whats the best way to assign a string as a key in Javascript, considering what I'm trying to do?</p>