title: Accessing private methods of a JS Function
body: <p>I have following javascript code</p>
  
  <pre><code>function MyFunc () {
  
      var add = function () {
          return "Hello from add";
      };
  
      var div = function () {
           return "Hello from div";
      };
  
      var funcCall =  function (obj) {
  
          if (!obj) {
              throw new Error("no Objects are passed");
          }
        return obj.fName();
  
  
      };
  
    return {
      func: function (obj) {
        funcCall(obj);
      }
    };
  
  }
  
  var lol = new MyFunc();
  </code></pre>
  
  <p>When <code>lol.func({fName: add});</code> is passed it should invoke the function private function <code>add</code> or when <code>lol.func({fName: div});</code> is passed it should invoke the private div function. What i have tried does not work. How can i achieve this.</p>
  
  <p><a href="https://jsbin.com/lalenayixo/edit?js,console" rel="nofollow noreferrer">DEMO</a></p>