Uncurry a curried function of n parameters in javascript
<p>If f :: a -> b -> c is curried then uncurry(f) can be defined as:</p>

<p>uncurry :: (a -> b -> c) -> ((a, b) -> c)</p>

<p>I'm trying to implement the above function in javascript. Is my below implementation correct and generic enough or are there are any better solution?</p>

<pre><code>const uncurry = f =&gt; {
  if (typeof f != "function" || f.length == 0)
    return f;

  return function()
  {     
    for (let i = 0; i &lt; arguments.length; i++){
      f = f(arguments[i]);
    }

    return f;
  };
}


const curry = f =&gt; a =&gt; b =&gt; f(a, b);
const curriedSum = curry((num1, num2) =&gt; num1 + num2);
console.log(curriedSum(2)(3)); //5

console.log(uncurry(curriedSum)(2, 3)); //5
</code></pre>