Originally Posted by mrhoo
The change is read in the instances and in the prototypes,
not in the functions.
var b=new B();
alert(b.constructor); // returns function A
alert(B.prototype.constructor); // // returns function A
But since title property is in the constructor function, and not the prototype, b.title is 'B'.
If you define a property or method in the prototype it will be inherited
Maybe I didn't clearly describe my issue.
I create instance b first by b = new B();
then I change B's prototype B.prototype = new A();
As b itself doesn't have constructor property and it inherits the property from its prototype, so b.constructor should be identical with B.prototype.constructor, i.e. both of them should be "function A() ...". But the test result is b.constructor is still "function B() ...".
I also tested creating the object after setting the prototype, both of them are "function A() ...".
I am wondering what happened behind the invocation order change.