i created new instance('instance1' and 'instance2') using 'new' keyword. just like this.
1.with 'Child.prototype.constructor = Child'
function Parent() {
}
function Child() {
Parent.call(this);
}
Child.prototype = new Parent();
Child.prototype.constructor = Child;
var instance1 = new Child();
2.without 'Child.prototype.constructor = Child'
function Parent() {
}
function Child() {
Parent.call(this);
}
Child.prototype = new Parent();
var instance2 = new Child();
And i can check the constructor of instance using 'instanceof' keyword.
instance1 instanceof Child // true
instance1 instanceof Parent // true
this result is make sense, because i clearly wrote 'Child.prototype.constructor = Child;'. so instanceof keyword can find both constructor. BUT
instance2 instanceof Child // true
instance2 instanceof Parent // true
. but this result is not make sense for me. i expected
instance2 instanceof Child // false
because i did not write 'Child.prototype.constructor = Child;'.
Why???