For example:
function Constructor() {
this.peoperty = 1;
this.myMethod1 = function() {
//do something
};
this.myMethod2 = function() {
let a = myMethod3();
}
/*no 'this' keyword for myFunction3,because
I am not going to call myFunction3 anywhere else,
except inside this particular Constructor*/
myMethod3 = function() {
let b = 0;
return b;
};
}
var hello = new Constructor();
I assume this
keyword refers to the instance when creating a variable use new
keyword.
The question is, if the myMethod3
will only be called inside that constructor, can I not use this
keyword for myMethod3
, because I am not going to use hello.myMethod3
anywhere in my code. Does this save some memory while running, since I guess only properties/methods that bind with a this
keyword will occupy memory spaces for each instance created with a new
keyword?