1) Setting the Product instance as a prototype object for Prod_dept adds the values ββand methods of this Product instance (and its prototype) to the prototype chain of all your Prod_dept instances.
It also allows instanceof show that an object created from Product_dept is an instance of both constructors.
var a = new Product(); var b = new Product_dept(); a instanceof Product // true a instanceof Product_dept // false b instanceof Product // true b instanceof Product_dept // true
2) Since this is a new object created by Prod_dept , .call allows you to set this object as the value of the Product method, so any Product method with this will execute on this new instance of Prod_dept (in this case, code is executed to add values ββto the properties name and value ).
3) It just creates a new instance from the constructor Prod_dept .
In general, this is one template for using the prototype JavaScript inheritance mechanism.
source share