title: Functions that return a function
body: <p>I'm stuck with this concept of 'Functions that return functions'. I'm referring the book 'Object Oriented Javascript' by Stoyan Stefanov.</p>
  <p><strong>Snippet One:</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function a() {
    alert("A!");
  
    function b() {
      alert("B!");
    }
  
    return b();
  }
  
  var s = a();
  alert("break");
  s();</code></pre>
  </div>
  </div>
  </p>
  <p><strong>Output:</strong></p>
  <pre><code>A!
  B!
  break
  </code></pre>
  <p><strong>Snippet Two</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function a() {
    
      alert('A!');
  
      function b(){
          alert('B!'); 
      }
  
      return b;
  }
  
  var s = a();
  alert('break');
  s();</code></pre>
  </div>
  </div>
  </p>
  <p><strong>Output:</strong></p>
  <pre><code>A!
  break
  B!
  </code></pre>
  <p>Can someone please tell me the difference between returning <code>b</code> and <code>b()</code> in the above snippets?</p>