What is 'Currying'?

前端 未结 18 1266
遥遥无期
遥遥无期 2020-11-21 05:26

I\'ve seen references to curried functions in several articles and blogs but I can\'t find a good explanation (or at least one that makes sense!)

18条回答
  •  日久生厌
    2020-11-21 06:15

    Here is the example of generic and the shortest version for function currying with n no. of params.

    const add = a => b => b ? add(a + b) : a; 
    

    const add = a => b => b ? add(a + b) : a; 
    console.log(add(1)(2)(3)(4)());

提交回复
热议问题