currying

What is 'Currying'?

情到浓时终转凉″ 提交于 2019-11-25 22:16:35
问题 I\'ve seen references to curried functions in several articles and blogs but I can\'t find a good explanation (or at least one that makes sense!) 回答1: Currying is when you break down a function that takes multiple arguments into a series of functions that each take only one argument. Here's an example in JavaScript: function add (a, b) { return a + b; } add(3, 4); // returns 7 This is a function that takes two arguments, a and b, and returns their sum. We will now curry this function: