Sometimes it's easier to visualize relationships, so you realize that in many cases we have foo.bar === Foo.prototype.bar; // true foo.bar === Foo.prototype.bar; // true

When you create an instance of foo prototype property of the foo constructor is set as a special reference foo ( __proto__ ), where if you are trying to access a property that does not exist directly on foo next place that the property looks for is this link.
This means that if you expect that foo will not be changed in such a way as to hide the property from this object, it does not matter if you try to search through foo.bar or Foo.prototype.bar , since this is one and the same.
However, as you can see, not everyone will have the same __proto__ path, so you could not assume that obj.slice will exist, for example. This means that if you don't have an Array instance, but you want to cut it off, you need to reference the slice, although you know that there is a way like Array.prototype.slice
source share