I read that adding functions to an object will digest more memory and then add functions to the prototype of the object.
function Obj() {
this.M = function() {
}
var o = new Obj();
The idea was that for each Obj construct, a new function is created and applied to Obj, which increases memory usage. For 1000 instances of Obj, you need to create 1000 functions.
function Obj() {
}
Obj.prototype.M = function() {
var o = new Obj();
For 1000 instances of Obj, in this case only one function is created. Grid of overall memory saving 999 * sizeof (M).
Is this really so? If so, then in which category does the following fall under:
function Obj() {
Obj.prototype.M = function() {
}
var o = new Obj();
, Obj . , , N N .
-, , .