DEV Community

Discussion on: JS interview in 2 minutes / Currying πŸ₯˜

Collapse
 
kspeakman profile image
Kasey Speakman

Currying is mainly a way to setup a function for easier partial application -- providing only some of the function arguments. You can do partial application without currying, but it is less convenient.

// currying partial application
let add = a => b => a + b
let add2 = add(2)
add2(7)
// 9

// non-currying partial application
let add = (a, b) => a + b
let add2 = b => add(2, b)
add2(7)
// 9
Enter fullscreen mode Exit fullscreen mode
Collapse
 
hexnickk profile image
Nick K

Thanks πŸ™ Added a note with a link to this comment to the post itself.