JavaScript curry: what are the practical applications?
Here’s an interesting AND practical use of currying in JavaScript that uses closures: function converter(toUnit, factor, offset, input) { offset = offset || 0; return [((offset + input) * factor).toFixed(2), toUnit].join(” “); } var milesToKm = converter.curry(‘km’, 1.60936, undefined); var poundsToKg = converter.curry(‘kg’, 0.45460, undefined); var farenheitToCelsius = converter.curry(‘degrees C’, 0.5556, -32); milesToKm(10); // returns … Read more