Last active
October 5, 2016 08:18
-
-
Save digitalfun/1c2c7e5860186deb4537 to your computer and use it in GitHub Desktop.
[js] Javascript Module Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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