title: Distinguish normal function or closure in JavaScript?
body: <p>I was confused with how to call a function which maybe a clousre When I learn JavaScript. I use Java before.</p>
  
  <p>When I write a middleware such as for koa2, I write:</p>
  
  <pre><code>async function gzip(ctx, next) { }
  </code></pre>
  
  <p>If we need an option:</p>
  
  <pre><code>function gzipWithOption(option){
     return async function gzip(ctx, next) { }
  }
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>module.exports = options =&gt; {
    return async function gzip(ctx, next) { }
  }
  </code></pre>
  
  <p>My confusion is, how koa2 or other compiler system to know if it should call:</p>
  
  <pre><code>theDarkFunc(param)
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>theDarkFunc(option)(param)
  </code></pre>
  
  <p>How a programmer know that? Only by reading doc?</p>