title: calling a javascript function with multiple closures
body: <pre><code>    function sum(a) {
          var sum = a
          function f(b) {
              sum += b
              return f
          }
  
          f.toString = function () { return sum }
          return f
      }
      var a = sum(0)(1)(2)(3)(4)(5);
  </code></pre>
  
  <p>Can someone explain to me how does this code works? I really don't get how to call function with multiple closures in such a way.
  And why when i print a in the browsers console the result is "function 15" and not just 15</p>