JS Currying vs. Partial Application Explained in 3 Sentences and 4 Lines of Code
((a, b, c, d) => a + b + c + d )(1, 2, 3, 4) // 10
This function can be written as…
(a => b => c => d => a + b + c + d)(1)(2)(3)(4) // 10
…with each function taking a single function as an argument and returning a single function with the previous environments wrapped in closures — currying.
let partiallyApplied = (a => b => c => d => a + b + c + d)(1)(2)(3)
Stop anywhere before the end, and you’ve partially applied the curried function. Now just continue from where you left off to get the final output.
partiallyApplied(4) // 10