title: Multiple nested functions in javascript
body: <p>I am kind of back engineering a javascript project and need to inject a function into some already writeen code.</p>
  
  <p>I want to be able to call something like the following function in javascript:</p>
  
  <p>human.mouth.shout(word);</p>
  
  <p>So this would call the function that makes the object 'shout'.</p>
  
  <p>My question is, how I create child attributes of the human object. As far as I know, I can only have one nested function in javascript, so at the most basic I have something like this:</p>
  
  <pre><code>function HumanObj(){
      this.shout = function(word){
          alert(word);
      }
  }
  </code></pre>
  
  <p>Then to call this, I would use:</p>
  
  <pre><code>var human = new HumanObj;
  human.shout("HELLO WORLD");
  </code></pre>
  
  <p>So this would give us our alert: "HELLO WORLD".</p>
  
  <p>So how would I break this up so I could call it using the following?</p>
  
  <pre><code>var human = new HumanObj;
  human.mouth.shout("HELLO WORLD");
  </code></pre>
  
  <p>Have tried this, but didn't work - assume you can't have too many levels of nested functions...</p>
  
  <pre><code>function HumanObj(){
      this.mouth = function(){
           this.shout = function(word){
              alert(word);
          }
      }
  }
  </code></pre>
  
  <p>Thanks!</p>