The name "currying" is named after the mathematician and has nothing to do with "currying" a favour, or the spicy dish!
Currying exists in other programming languages (as well as in mathematics) and has to do with splitting the arguments of functions, into functions with one argument each...
...so here we have an example without currying:
// non-curried way
let entity = (attr1, attr2, attr3) =>
attr1 + ' is the ' +
attr2 + ' guy who wears the ' +
attr3 + '!'
console.log(entity('Kyle', 'American', 'orange jacket'));
// Kyle is the American guy who wears the orange jacket
With currying, we can split the arguments up into smaller functions:
// curried way
let curriedEntity =
attr1 =>
attr2 =>
attr3 =>
attr1 + ' is the ' +
attr2 + ' guy who wears the ' +
attr3 + '!'
/* we can create a person */
let person = curriedEntity('Kyle')
let nationalizedPerson = person('American')
let uniformedPerson = nationalizedPerson('orange jacket')
console.log(uniformedPerson)
// Kyle is the American guy who wears the orange jacket
/* now we can create another person */
person = curriedEntity('Hans')
nationalizedPerson = person('German')
uniformedPerson = nationalizedPerson('tall army boots')
console.log(uniformedPerson)
// Hans is the German guy who wears the tall army boots