What is Currying in JavaScript
Mahin Tazuar
Posted on October 4, 2021
hascale curry brough this code pattern. That is not new concenpt , Its just a code pattern which is brough hascale curry.This defination is converting a function which has multiple perameter and converted to a single perameter.
Example : -
function curryFunc(x){
return function(y){
return function(z){
return x+y+z;
}
}
}
console.log(curryFunc(1)(2)(3))
Its based one things , we want to decrease function perameter.
When this function call by first time or first function call with paremeter. This function call partial function.
Example: -
function curryFunc(price){
return function(disc ){
return price+disc;
}
}
const user1 = curryFunc(3) // that is called partial function
const result = user1(35)
console.log(result)
💖 💪 🙅 🚩
Mahin Tazuar
Posted on October 4, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.