A class I'm writing in node.js is as below:
module.exports = exports = function(){ return new ClassA() };
function ClassA(){
this.myvariable = 0;
}
I have a function that I want to be private. To my understanding if the function is declared outside of the constructor, it will essentially be a static function which wouldn't be able to reference this.myvariable.
Is the correct way of dealing with this to declare the function within the constructor like this:
//within constructor
this.myFunction = function myFunction(){
console.log(this.myvariable)
}
Or is there a better way of doing it that doesn't leave me with a potentially huge constructor?
EDIT: It looks like I've misunderstood something here because the above code doesn't even work...