Skip to content

Instantly share code, notes, and snippets.

@max-mapper
Last active December 16, 2015 23:39
Show Gist options
  • Save max-mapper/5515039 to your computer and use it in GitHub Desktop.
Save max-mapper/5515039 to your computer and use it in GitHub Desktop.
client side module pattern exmaple
// assuming you have $ defined
var $ = jqueryblablah
// way 1
function addFunctions(global) {
function a() {}
function b() {}
global.a = a
global.b = b
}
// way 2
function addFunctions(global) {
global.a = function() {}
global.b = function() {}
}
addFunctions($)
// way 3
(function addFunctions(global) {
global.a = function() {}
global.b = function() {}
})($)
// lets you do this:
$.a()
$.b()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment