title: Javascript: Checking if an object has no properties or if a map/associative-array is empty
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object-from-json">How do I test for an empty Javascript object from JSON?</a>  </p>
  </blockquote>
  
  
  
  <p>Is there an easy way to check if an object has no properties, in Javascript? Or in other words, an easy way to check if a map/associative array is empty? For example, let's say you had the following:</p>
  
  <pre><code>var nothingHere = {};
  var somethingHere = {foo: "bar"};
  </code></pre>
  
  <p>Is there an easy way to tell which one is "empty"? The only thing I can think of is something like this:</p>
  
  <pre><code>function isEmpty(map) {
     var empty = true;
  
     for(var key in map) {
        empty = false;
        break;
     }
  
     return empty;
  }
  </code></pre>
  
  <p>Is there a better way (like a native property/function or something)?</p>