Skip to content

Instantly share code, notes, and snippets.

@gavinblair
Created November 22, 2013 16:04
Show Gist options
  • Save gavinblair/7602291 to your computer and use it in GitHub Desktop.
Save gavinblair/7602291 to your computer and use it in GitHub Desktop.
Pattern for creating a JavaScript plugin, from http://codereview.stackexchange.com/a/21147
(function(ns){
//private scoping
var privVar = '...';
function priv(){...}
//expose a function
ns.myFunc = function(){...};
}(this.myLib = this.myLib || {}));
//using the exposed myFunc
myLib.myFunc();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment