title: Can I drop IIFE when I have const inside function in JavaScript
body: <p>Let's say I have a function <code>myFunction</code> which in it's body uses results of other function <code>otherFunction</code> and those results are constant per every invocation.</p>
  
  <pre><code>function myFunction() {
    doSomething(otherFunction());
  }
  </code></pre>
  
  <p>In the past I used IIFE-s to invoke <code>otherFunction</code> only once and so optimize the code:</p>
  
  <pre><code>var myFunction = (function() {
    let otherFunctionResult = otherFunction();
  
    return function() {
      doSomething(otherFunctionResult);
    };
  }());
  </code></pre>
  
  <p>I wonder if ES6 <code>const</code> keyword would achieve the same result without using IIFE:</p>
  
  <pre><code>function myFunction() {
    const OTHER_FUNCTION_RESULT = otherFunction();
    doSomething(OTHER_FUNCTION_RESULT);
  }
  </code></pre>
  
  <p>Can I expect <code>const</code> to be optimized so that <code>otherFunction</code> is invoked only once? That would greatly simplify the code. </p>