Why my constuctors have “prototype” property?
This is a topic covered a million times. Still, I don’t find any existing answers on blog articles or stackoverflow specific enough. They mostly suffices for development, but not if you want accurate definitions. So we want specificity, let’s look at the specs.
Function.prototypeare intrinsic objects. They are created upfront. They are not created by familiar program mechanisms. They are given. http://www.ecma-international.org/ecma-262/6.0/#sec-well-known-intrinsic-objects
Most function instances are constructors, except special cases (e.g. decodeURI is not a constructor). Constructors are function instances that supports [[Construct]]. http://www.ecma-international.org/ecma-262/6.0/#table-6
The above is no surprise. The real question is, why all my constructors have
prototypeproperty (as own property)? Who set them? Answer is at MakeConstructor http://www.ecma-international.org/ecma-262/6.0/#sec-makeconstructor
Depending whether prototype argument is present, it will use passed argument or an object created from ObjectCreate(Object.prototype). Then it will set that to be “prototype” of the current constructor. In fact, all the calls to MakeConstructor have prototype argument omitted, except for generator functions and classes.
Now let’s take another look at the century old diagram. It all makes sense now: