title: Uncaught ReferenceError: <function> is not defined
body: <p>I have below codes in my jsp file.</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function() {
          var date = new Date();
          var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
  
          function getFirstDay() {
              return firstDay;
          }
          ;
  
          function getToday() {
              return date;
          }
          ;
      });
  &lt;/script&gt;
  
  &lt;script&gt;
      $('.datepicker').datepicker({
          format : 'yyyy-mm-dd',
          todayHighlight : true
      });
  
      $("#from_date").datepicker("setDate", getFirstDay());
      $("#to_date").datepicker("setDate", getToday());
      $("#from_date").datepicker('update');
      $("#to_date").datepicker('update');
  &lt;/script&gt;
  </code></pre>
  
  <p>But when page load, I got below error on js console.</p>
  
  <pre><code>Uncaught ReferenceError: getFirstDay is not defined 
  </code></pre>
  
  <p>How could I solve this ?</p>