Javascript Private Variable Through Closure Nov 16th, 2011 12:11 pm Defining Javascript class private instance variable Example: 1 2 3 4 5 6 7 function MyClass(a) { // constructor this.getA = function() { return a; } } MyClass.prototype.myFunc = function() { return this.getA() + 1000; // do something with a }