Why does the hasOwnProperty alias falsely return undefined?
<pre><code>function object() {
    var F = function() {};
    F.prototype = {
        alias: {},
        hasOwnProperty: function() { return false; },
        hasProperty: function(obj, prop) {
            for (var i = 0; i &lt; obj.length; i++) {
                if (obj[i] !== prop) return false;
                else if (obj[i] === prop) return true;
                else return undefined;
            }
        }
    };
    return new F();
}

var newObj = object();
newObj.alias.msg = "Hello";
console.log(newObj.hasProperty(newObj.alias, "Hello"));
</code></pre>

<p>It returns undefined for newObj.hasProperty(newObj.alias, "Hello"). Why?</p>
