1const curry = (f, ...args) =>
2 args.length >= f.length
3 ? f(...args)
4 : (...moreParams) => curry(f, ...args, ...moreParams)
5
6const greet = curry((msg, name) => {
7 console.log(`${msg}`, name)
8});
9
10// Curry usage example:
11
12const welcomeGreet = greet("Welcome")
13const byeGreet = greet("Bye bye")
14
15welcomeGreet("Pablo (sairov)")
16welcomeGreet("Ale zapata")
17
18byeGreet("Fernando")
19byeGreet("Juan Sonido")
20
1//event handling using currying
2const handleChange = (fieldName) => (event) => { saveField(fieldName, event.target.value)}<input type="text" onChange={handleChange('email')} ... />
1export default connect(mapStateToProps)(TodoApp)//react-redux example of currying