function to_array(array) {
  return [].slice.call(array);
}

function curry(fn) {
  var init_args = [].slice.call(arguments, 1);
  var len = fn.length;
  return function() {
    var args = init_args.slice();
    function call() {
      args = args.concat(to_array(arguments));
      if (args.length >= len) {
        return fn.apply(null, args);
      } else {
        return call;
      }
    };
    return call.apply(null, arguments);
  };
}
function add(a,b,c) {
  return a+b+c;
}
var test = curry(add);
console.log('0', test(2,3,4));
console.log('1', test(2)(3)(4));
console.log('2', test(2,3)(4));
console.log('3', test(2)(3,4));
console.log('4', test(2,3,4));
console.log('5', test(2,3)(4,5));
var test2 = curry(add, 2);
console.log('6', test2(3,4));
console.log('7', test2(3)(4));

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.