title: JS Revealing Module Pattern - access private variables via public methods
body: <p>i created <code>txtModule</code> module using Revealing Module Pattern with jquery,</p>
  <p>i want print value of a input tag to a console..
  for that exposed test method as public
  as shown below code</p>
  <pre><code>        var txtModule = (function(window,$){
  
              var txt = {
                  topics:{},
                  test:function(){
                      console.log(this.input.val());    
                  },
                  _init:function(){
                      this._cacheDom();                        
                  },
                  _cacheDom:function(){  
                      this.input = $(&quot;input#c_input&quot;);                                     
                  },
              }
              
              txt._init();
              
              return {                
                  test : txt.test,
              }
          });
      
            
          var v = txtModule(window,$);
          v.test();
  </code></pre>
  <p>when execute test public method when try to access <code>this.input</code> variable there is a error appear as below</p>
  <pre><code>Uncaught TypeError: Cannot read properties of undefined (reading 'val')
  </code></pre>
  <p>I want to know how can correctly expose test method to outside to access <code>this.input</code></p>