Skip to content

Instantly share code, notes, and snippets.

@pukhalski
Last active December 17, 2015 09:58
Show Gist options
  • Save pukhalski/5590920 to your computer and use it in GitHub Desktop.
Save pukhalski/5590920 to your computer and use it in GitHub Desktop.
var APP = APP || {};
// module-"class" (constructor)
APP.NewModule2 = (function (APP, $, undefined) {
// static variables and methods
var x = Math.random();
return function () {
// private variables and methods
var y = Math.random();
// public variables and methods
this.z = Math.random();
this.getX = function () {
return x;
};
this.getY = function () {
return y;
};
};
}(APP, jQuery));
var APP = APP || {};
// module-literal
APP.newModule1 = (function (APP, $, undefined) {
// private vars and methods
var bar = 0;
return {
// public vars and methods
foo: function () {
// ...
}
};
})(APP, jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment