Skip to content

Instantly share code, notes, and snippets.

@wilwang
Created April 22, 2013 03:15
Show Gist options
  • Save wilwang/5432217 to your computer and use it in GitHub Desktop.
Save wilwang/5432217 to your computer and use it in GitHub Desktop.
javascript module pattern :: creates anonymous function that gets called immediately and returns the public interface
var myNamespace = (function() {
// private functions for your namespace
var getSelText = function() {
...
};
return {
run: function() {
var selectedText = getSelText();
alert (selectedText);
}
};
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment