title: Javascript: difference between calling lambda function or just a direct expression?
body: <p>I sometimes see JS constructs like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>var foo = (function(){ return some_expression; })();
  </code></pre>
  
  <p>What can be the reason for this? Is this in any way different to the much simpler:</p>
  
  <pre><code>var foo = some_expression;
  </code></pre>
  
  <p>I happen to came across such an example <a href="https://www.paulirish.com/2011/requestanimationframe-for-smart-animating/" rel="nofollow noreferrer">here</a> (the <code>window.requestAnimFrame = ...</code> code) but I've seen it in many others places.</p>
  
  <p>I know one reason to wrap stuff in a lambda function is to keep variables local, but that doesn't apply in this particular example.</p>