-
What is function currying? |
Beta Was this translation helpful? Give feedback.
Answered by
hixb
Jul 16, 2022
Replies: 1 comment
-
` // Currying后 add(1, 2) // 3 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
xiao-ice
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`
// 普通的add函数
function add(x, y) {
return x + y
}
// Currying后
function curryingAdd(x) {
return function (y) {
return x + y
}
}
add(1, 2) // 3
curryingAdd(1)(2) // 3
`