title: for..in and hasOwnProperty
body: <blockquote>
  <p><strong>Possible Duplicate:</strong> <br/>
  <a href="https://stackoverflow.com/questions/135448/how-do-i-check-if-an-object-has-a-specific-property-in-javascript">How do I check if an object has a specific property in JavaScript?</a></p>
  </blockquote>
  
  <p>I found the following snippet in Twitter's JavaScript files. Why do they need to call the <code>hasOwnProperty</code> function to see <code>dict</code> has the <code>key</code> property? The <em>for</em> loop is running for each 'key' in 'dict' which means 'dict' has 'key'. Am I missing a point?</p>
  <pre><code>function forEach(dict, f) {
      for (key in dict) {
          if (dict.hasOwnProperty(key))
              f(key, dict[key]);
      }
  }
  </code></pre>