[javascript] How does JavaScript .prototype work?

It's important to understand that there is a distinction between an object's prototype (which is available via Object.getPrototypeOf(obj), or via the deprecated __proto__ property) and the prototype property on constructor functions. The former is the property on each instance, and the latter is the property on the constructor. That is, Object.getPrototypeOf(new Foobar()) refers to the same object as Foobar.prototype.

Reference: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes