javascript currying implementation es6

Solutions on MaxInterview for javascript currying implementation es6 by the best coders in the world

showing results for - "javascript currying implementation es6"
Larry
23 Aug 2019
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
Elyna
01 Jun 2018
1//event handling using currying
2const handleChange = (fieldName) => (event) => {  saveField(fieldName, event.target.value)}<input type="text" onChange={handleChange('email')} ... />
Anthony
05 Oct 2018
1export default connect(mapStateToProps)(TodoApp)//react-redux example of currying