Possible Duplicate:
Why is it necessary to set the prototype constructor?
I'm struggling to understand the necessity of setting the 'constructor' property of a javascript object to the subclass when building a hierarchy. I find that the code below does what is expected without changing the constructor property, but in almost all references I find about the subject the constructor is set explicitly. Am I missing something ? (I don't find any explicit use of it in the ECMAScript specs either).
A = function() {
this.value = "a";
this.A = function() {
window.alert( this.value + " instanceof A : " + ( this instanceof A ) );
}
}
B = function() {
this.value = "b";
this.B = function() {
window.alert( this.value + " instanceof B : " + ( this instanceof B ) );
}
}
B.prototype = new A();
test = function() {
var b = new B();
b.A();
b.B();
}