title: Removing object properties using jQuery map() and dynamic property names?
body: <p>I'm trying to remove properties from an object if its name has a length greater than 1, using <a href="http://api.jquery.com/jQuery.map/" rel="nofollow"><code>.map()</code></a>:</p>
  
  <pre><code>var result = { a :{}, b : {}, invalid : {} };
  
  result = $.map(result, function(val, prop){
     return prop.length &gt; 1 ? null : { prop : val };
  });
  
  console.log(result);
  </code></pre>
  
  <p>Console shows that <code>result</code> is <strong>now an array</strong> (not an object as it should be) and <strong><code>prop</code> is taken literally</strong> (i.e. there are many properties named "prop" inside the array).</p>
  
  <p>Any help would be great!</p>
  
  <p><strong>EDIT</strong>: solution combining <code>.map()</code> and <code>delete</code>:</p>
  
  <pre><code>$.map(result, function(val, prop){
     if(prop.length &gt; 1) delete result[prop]; // val is unused but required
  });
  </code></pre>