title: Comparing property names in JavaScript
body: <p>I'm trying to write a function to compare property names, but I'm not sure how to do so. This is what I've tried, and it's not working as intended.</p>
  
  <pre><code>function propCompare(objA, objB) {
      // assumes both objects have same length
      for (var prop in objA) {
          if (objB[prop] === undefined)
              return false;
          else {
              return true;
          }
      }
  }
  </code></pre>
  
  <p>What I'm trying to obtain is if <code>objA</code> has a property that <code>objB</code> doesn't have, then don't bother checking further, and just return <code>false</code>. If everything matches up, return <code>true</code>.</p>