In JavaScript, I'm trying to achieve private variables (like in other OOP languages).
Is it possible only through closures OR is there any other way by which we can implement private variables?
Any examples would be really helpful.
For a class (function) it's just using "var" vs "this.":
function myObject() {
var myPrivateVariable = 10;
this.myPublicVariable = 20;
}