Skip to content

Instantly share code, notes, and snippets.

@Webastronaut
Last active February 16, 2024 11:20
Show Gist options
  • Save Webastronaut/8443106 to your computer and use it in GitHub Desktop.
Save Webastronaut/8443106 to your computer and use it in GitHub Desktop.
Module pattern
var myNamespace = myNamespace || {};
myNamespace.myFancyModule = (function() {
var public = {},
private = {};
private.concatString = function(str) {
return 'Hello ' + str;
};
public.init = function(name) {
alert(private.concatString(name));
};
return public;
})();
$(function() {
myNamespace.myFancyModule.init('Module Pattern');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment