There is no idea of inheritance
per say in JavaScript. Your Calculator
thing is basically an object and it has a property called prototype
, which is used as, well, a prototype for all instances of the Calculator
object.
basically calculator = new Calculator
will be an instance of Calculator
, but internally all it's properties (until you explicitly change them) will point to Calculator.prototype
. In other words, a new calculator
is pretty much the same object as Calculator.prototype
but with a different object-id inside of the JavaScript interpreter.
So, in the end calculator
is an instance of Calculator
and eventually Object
, but it does not 'inherit' from Calculator
, coz there is no inheritance, there are the object prototypes which can be instances of anything.