title: Function in function in class
body: <p>I have a class named Terminal in which I have a function constructor in which i have an anonymous function in which I would like to get access to the output() function in Terminal class. How can I do this?</p>
  
  <p>Using this.output() throws an error. (this.output is not a function)</p>
  
  <pre><code>class Terminal
  {
      constructor(contentID, inputID, options)
      {
          if (!contentID || !inputID || !options)
          {
              return false;
          }
          this.cid = contentID;
          this.iid = inputID;
          if (!options['pcName'] || !options['username'])
          {
              return false;
          }
          this.pcname = (options['pcName'].replace('&lt;', '&amp;lt;')).replace('&gt;', '&amp;rt;');
          this.username = options['username'];
          this.version = '0.01';
          // commands
          this.commandsList = [];
          this.commandsList['whoami'] = function(){ Terminal.output('lol') };
  
          console.log('terminal.js version ' + this.version + ' initializing');
          this.output('ja', true);
          this.output('whoami', true);
          this.output('i dont know bro', false, 'whoami');
      }
  
      output (text, prefix, cmdName) // cmdName is matters only when prefix is false
      {
          if (this.cid &amp;&amp; text)
          {
              if (prefix == true)
              {
                  text = this.username + '@' + this.pcname + ':~$ ' + text;
              }
              else if (cmdName)
              {
                  text = cmdName + ': ' + text;
              }
              var con = document.getElementById(this.cid);
              con.innerHTML = con.innerHTML + text + '&lt;br&gt;';
          }
      }
  
      makeCommand (cmd)
      {
          if (cmd &amp;&amp; cmd != '' &amp;&amp; this.commandsList)
          {
              cmd = (cmd.replace('&lt;', '&amp;lt;')).replace('&gt;', '&amp;rt;');
              if (this.commandsList[cmd])
              {
                  console.log('Executing ' + cmd);
                  this.commandsList[cmd]();
              }
          }
      }
  }
  </code></pre>