What is currying in JavaScript?
It is an advanced technique of working with functions that can accept multiple arguments. It will transform this function into a series of functions, where every function will accept one argument:
Non-curried version //
const sum = (a, b, c)=>{
return a+ b + c
}
console.log(sum(2, 3, 5)) // 10
Curried version //
const sumCurry =(a) => {
return (b)=>{
return (c)=>{
return a+b+c
}
}
}
console.log(sumCurry(2)(3)(5)) // 10
BY Best Interview Question ON 10 Aug 2022