Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dannylloyd/1002947 to your computer and use it in GitHub Desktop.
Save dannylloyd/1002947 to your computer and use it in GitHub Desktop.
Information hiding in JavaScript, private instance variables and methods
function superClass() {
var self = this; // used when you want to reference an instance of this object from private methods
this.PublicIVar = "asdafd";
var privateIVar = "encapsulated";
function PrivateFunction() {
}
this.PublicFunction = function () {
};
}
var instance = new superClass();
instance.PublicFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment