Here’s what my code looks like:
Random = function(name) {
this.name = name;
this.addSomething = function(a, b) {
return a + b;
}
}
Random.prototype.addStuff = function(a, b, c, d) {
return this.addSomething(a, b) + this.addSomething(b, d);
}
I need this.addSomething to only be available in the function itself and its prototypes, however this isn’t working.
Could someone point me in the right direction and show me how to do this? Thanks.
The only way to make “private” members/methods is something like this:
Edit: as RobG mentioned in his answer, this article by Douglas Crockford will help you understanding how public, private and privileged members/methods work in Javascript. It’s an extremely reccomended reading.