title: Javascript:What is meaning of sum(2)(3) //returns 5;
body: <p>Here is code blow to return it's value.         </p>
  
  <pre><code>function sum(a){
    return function(b){
      return a+b;
    }
  }
  sum(2)(3);
  </code></pre>
  
  <p>It returns 5 but if I type code:</p>
  
  <pre><code>function sum(a){
    function add(b){
      return a+b;
    }
  return add(b);
  }
  </code></pre>
  
  <p>It doesn't return expected value 5. I don't even understand how <strong>sum(2)(3)</strong> calls function. Any explanation for this is very much appreciated.</p>