I have question regarding to the inheritance/prototype in Javascript, so if there's one constructor contains one method "greeting", but there's also another "greeting" method attached to the prototype of this constructor, then which implementation does it use if one object created using this constructor and calling this method? Is the method getting "overriden" or "shadowed"?
Asked
Active
Viewed 76 times
0
-
1Can you share executable demo/snippet or [JSFiddle](https://jsfiddle.net/) ? [_Create a Minimal, Complete, and Verifiable example_](http://stackoverflow.com/help/mcve) – Rayon Jul 15 '16 at 19:41
1 Answers
0
Short answer: yes, it is being overridden.
From MDN:
JavaScript objects are dynamic "bags" of properties (referred to as own properties). JavaScript objects have a link to a prototype object. When trying to access a property of an object, the property will not only be sought on the object but on the prototype of the object, the prototype of the prototype, and so on until either a property with a matching name is found or the end of the prototype chain is reached.

TimoStaudinger
- 41,396
- 16
- 88
- 94