How does javascript look up a member of an object through its prototype chain?
<p>When evaluating the value of 
<code>myObject.myMember</code></p>

<p>My guess is that javascript will try to look up the "myMember" entry in:</p>

<pre>

    myObject
    myObject.constructor.prototype
    myObject.constructor.prototype.constructor.prototype
    myObject.constructor.prototype.constructor.prototype.constructor.prototype
    .......

</pre>

<p>until succeed.</p>

<p>The following code seems to validate my guess </p>

<pre><code>var MyClass1=function(){
    this.key1="value1"; 
};
var myObject=new MyClass1();

MyClass1.prototype.key2="value2";

console.log(myObject.constructor.prototype.key2=="value2"); //true
console.log(myObject.key2=="value2"); //true   :)
</code></pre>

<p>But the following code proves my guess is wrong</p>

<pre><code>var MyClass1=function(){
    this.key1="value1"; 
};

var MyClass2=function(){
    this.key2="value2"; 
};

var myObject=new MyClass1();

MyClass1.prototype=new MyClass2();
console.log(myObject.constructor.prototype.key2=="value2");//true
console.log(myObject.key2=="value2");// false! why?
</code></pre>

<p>What is the actual algorithm by which javascript looks up a member of an object through its prototype chain?</p>
