title: How to call a function inside another function on document load
body: <p>First of all please ignore if this question if seems stupid as I am not that much good in javascript side.</p>
  
  <p>I need to call a function inside another function on document load. An example code is below. Here I need to alert the message 'my second alert'. How can I make it happen?. I know by initializing <code>alertSecond()</code> inside the function will work it, but is there any other way to do it?</p>
  
  <p>Thanks in advance</p>
  
  <pre><code>$(document).ready() {
  
  test();
  
  function test() {
      alert('my first alert');
      function alertSecond() {
          alert('my second alert')
      }
  }
  </code></pre>
  
  <p>}</p>