What Advantage Does HasOwnProperty Offer When Checking if a Property Exists As Part of An Object Literal?
<p>The code I'm referencing comes from <a href="http://stackoverflow.com/a/1961068/122164">this</a> answer:</p>

<pre><code>Array.prototype.getUnique = function(){
   var u = {}, a = [];
   for(var i = 0, l = this.length; i &lt; l; ++i){
      if(u.hasOwnProperty(this[i])) {
         continue;
      }
      a.push(this[i]);
      u[this[i]] = 1;
   }
   return a;
}
</code></pre>

<p>What is the purpose of <code>hasOwnProperty</code> here? I've ran a version of the method that does not use it and it works just the same:</p>

<pre><code>Array.prototype.getUnique = function(){
   var u = {}, a = [];
   for(var i = 0, l = this.length; i &lt; l; ++i){
      if(u[this[i]] !== undefined) {
         continue;
      }
      a.push(this[i]);
      u[this[i]] = 1;
   }
   return a;
}
</code></pre>
