All , In the classical inheritance language. such as Java , c# etc, It is true a new instance initialization of a sub Class will cause the base Class constructor execution before the sub Class's constructor is executed. But I am not sure whether It will be same in the javascript inheritance. Let's take a example . Says your have the code like below .
function Shape() {
this.x = 0;
this.y = 0;
};
If there is an object name rect
inherit from Shape
. supposed the constructor of Rectangle
looks like this.
function Rectangle(){
};
Rectangle.prototype = Object.create(Shape.prototype);
var rect= new Rectangle();
Would the constructor Shape
will be executed when the constructor Rectangle
is executed ? thanks.