title: What's the difference between these 2 functions in javascript
body: <p>Below is a piece of code from Eloquent Javascript's chapter-<a href="http://eloquentjavascript.net/10_modules.html" rel="nofollow">Modules</a>.</p>
  
  <pre><code>var dayName = (function() {
    var names = ["Sunday", "Monday", "Tuesday", "Wednesday",
                 "Thursday", "Friday", "Saturday"];
    return function(number) {
      return names[number];
    };
  })();
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>var dayName = function(number) {
    var names = ["Sunday", "Monday", "Tuesday", "Wednesday",
                 "Thursday", "Friday", "Saturday"];
    return names[number]; 
  };
  </code></pre>