Module pattern

var modulePattern = modulePattern || {};

modulePattern.sayIt = function() {

  var public = {};
  public.settings = [true, false, true];
  var self = this;

  function init() {

    console.log('private');
    
  }
  
  public.speak = function(string) {
    
      console.log(string);
    
  }

  return public;
  

}

console.log(modulePattern.sayIt().settings);
modulePattern.sayIt().speak('something');
// Won't work as not public
//modulePattern.sayIt().init();

Codepen

Worthy of Note

Worthy of Note is a site aimed at Web Designers & Developers. It offers a wide range of resources to help assist anyone in the web industry.

View