a.sharedValue = 'other value'
assigns the 'other value'
value to the sharedValue
property of the a
instance only.
The way the prototype chain works, is that property access will look at the object instance for whether it contains a specific property, and if it doesn't find the property, it will traverse up the prototype chain until it either:
- finds the property and returns the value of that property at whatever level of the prototype
- doesn't find the property on any of the prototypes and returns
undefined
You should also note that modifying a.sharedValue = 'other value'
will not have any affect on Module.prototype.sharedValue
.