title: Defining and calling function in one step
body: <p>Is there a way in Javascript to define a function and immediately call it, in a way that allows it to be reused? </p>
  
  <p>I know you can do one-off anonymous functions:</p>
  
  <pre><code>(function(i) {
      var product = i * i;
      console.log(product);
      // Can't recurse here because there's no (ECMA standard) way for the 
      // function to refer to itself
  }(2)); // logs 4
  </code></pre>
  
  <p>Or you can name a function then call it afterwards:</p>
  
  <pre><code>function powers(i) {
      var product = i * i;
      console.log(i * i);
      if (product &lt; 1e6) { powers(product) };
  }
  
  powers(2); // Logs 4, 16, 256...
  </code></pre>
  
  <p>But is there a cleaner way of defining and calling a function in one go? Sort of like a hybrid of both examples?</p>
  
  <p>Not being able to do this isn't preventing me from doing anything, but it feels like it would be a nice expressive way to write recursive functions or functions that need to be run on <code>$(document).ready()</code> but also later when situations change, etc.</p>