Skip to content

Instantly share code, notes, and snippets.

@digitalfun
Last active October 5, 2016 08:18
Show Gist options
  • Save digitalfun/1c2c7e5860186deb4537 to your computer and use it in GitHub Desktop.
Save digitalfun/1c2c7e5860186deb4537 to your computer and use it in GitHub Desktop.
[js] Javascript Module Template
//create namespace if not existing
var testProject = testProject || {};
//create a "module" inside the namespace
// this is a so called "power constructor"
testProject.module = (function () {
'use strict';
var that = {}; //create new base object or for inheritance use a "power constructor" or create a new object from a class to set the parent.
var privateElement = 10;
that.publicElement = function () {
privateElement = privateElement + 1;
return that;
};
return that;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment