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
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#