Skip to content

Instantly share code, notes, and snippets.

@JayDouglass
Created June 1, 2011 04:58
Show Gist options
  • Save JayDouglass/1001808 to your computer and use it in GitHub Desktop.
Save JayDouglass/1001808 to your computer and use it in GitHub Desktop.
Information hiding in JavaScript, private instance variables and methods
function ASDFClass() {
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 ASDFClass();
instance.PublicFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment