JSFiddle - React, Tailwind, and code Playground

by ZenMaster

JavaScript

Function.prototype.curry = Function.prototype.curry ||
function() {
    function argumentsToArray(args) {
        return Array.prototype.slice.call(args);
    }

    var args = argumentsToArray(arguments),
        that = this;

    return function() {
        return that.apply(null, args.concat(argumentsToArray(arguments)));
    };
};

var add = function(a, b) {
    return a + b;
};

var one = function(text) {
    return text;
};

var empty = function() {
    return 'test';
};

var add1 = add.curry(1);
console.log(add1(5));

var one1 = one.curry(1);
console.log(one1());

var empty1 = empty.curry();
console.log(empty1());