Use case for not declaring a function as a prototype of another custom function? <p>I'm trying to get my head around the proper way of declaring js functions within my existing custom objects.</p> <p>E.g. Usually I've done it this way to add functions to my existing object(s):</p> <pre><code>function whateverController() { this.doSomething = function() { } } </code></pre> <p>What is the advantage of doing it the following way?</p> <pre><code>function whateverController() { ...some random code } whateverController.prototype.doSomething = function() { } </code></pre> <p>From what I've been reading the latter example is the optimum way of declaring these functions to avoid having to recreate these functions every single a time I create a new whateverController object.</p> <p>Could someone please provide a good use case though where my former example would be better suited? If at all? Any good reading links would be helpful too!</p> <p>Is the latter method considered standard?</p>