Skip to content

Instantly share code, notes, and snippets.

@danieluhl
Created March 8, 2012 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieluhl/2003682 to your computer and use it in GitHub Desktop.
Save danieluhl/2003682 to your computer and use it in GitHub Desktop.
JavaScript Namespace
(function (libraryNamespace, $, undefined) {
// private properties
var privateProperty = 'default private';
// public properties
libraryNamespace.publicProperty = 'default public';
// private methods
function updatePublicProperty(newPublic) {
this.publicProperty = newPublic || 'new public';
}
// public methods
libraryNamespace.UpdatePrivateProperty = function (newPrivate) {
privateProperty = newPrivate || 'new private';
this.publicProperty = 'new public';
}
})(window.libraryNamespace = window.libraryNamespace || {}, jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment