benefit of using $(function(){})?

benefit of using $(function(){})?

Hello,

What's the benefit of using




  1. <script type="text/javascript">
  2. $(function()
  3. {
  4.   foo();
  5. }
  6. </script>

instead of the more concise:



  1. <script type="text/javascript">
  2.   foo();

  3. </script>

Thanks