There is a significant difference.
In type A, you reassign the property of the function prototype, in type B, you extend it (by reassigning certain methods). This will not be different if no one touches the prototype, but in fact the functions have the prototype property by default.
Try the following: type in console
var a=function(){console.log(123);};
Then access the prototype of this newly created function:
a.prototype;
In a browser environment, this log registers an object with the constructor and __proto__ . If you make type A, then a.prototype will be your entire object, in type B, you extend this object with the methods myMethodOne and myMethodTwo .
Regarding the practical difference (which basically plays a role when you want to use this function as a constructor function), especially about why the function has a prototype property by default (not to be confused with the prototype prototype chain of the created function), let me quote Eloquent Javascript, Chapter 6:
It is important to note the difference between how a prototype is associated with a constructor (through its prototype property) and how objects have a prototype (which can be obtained using Object.getPrototypeOf ). The actual prototype of the Function.prototype constructor, since constructors are functions. The prototype property will be the prototype of instances created through it, but is not its own prototype.
doldt source share