JS Revision - Revealing Module Pattern

Immediately invoked function wrapping a series of variables and functions, some of which are exposed by returning an object - the rest are private.

by andfinally

JavaScript

var Caculator = (function() {

  var number,
    output;

  var private = function (w) {
    console.log(w);
  };

  var add = function(x, y) {
    return firstNum + secondNum;
  };

  var multiply = function (x, y) {
    var product = x * y;
    private(product);
    return product;
  };
  
  return {
  	add: add,
    multiply: multiply
  };

})();