Javascript Module
A quick look into my way of creating modules:
/**
* A simple example how I structure my modules in javascript
*
*/
var Module = (function () {
/**
* This is the `constructor` of our `Module`
*
*/
var Module = function (options) {
// define some default options
this.options = {
key: 'value'
};
// merge the `options` with our defaults
for (var key in options) {
this.options[key] = options[key];
}
};
/**
* This is a `method` of or `Module`
*
*/
Module.prototype.method = function () {
};
return Module;
}());
Written by Yannick Albert
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#