Last Updated: December 26, 2018
·
537
· yckart

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;

}());