title: Assign and execute Javascript function simultaneously
body: <p>Is there a more elegant way of writing something like this, where myFunction is asigned to the function func but func is also executed during the assignment?</p>
  
  <pre><code>var myFunction = (function(){
    var func = function(){
      console.log('hello world');
    };
  
    func();
    return func;
  })();
  
  ...
  
  myFunction();
  </code></pre>