Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. const curry = fn => {
  2. if (fn.length === 0) {
  3. return fn;
  4. }
  5.  
  6. const _curry = (...args) => {
  7. if (fn.length <= args.length) {
  8. return fn.apply(null, args);
  9. }
  10. return _curry.bind(null, ...args);
  11. }
  12.  
  13. return _curry;
  14. }
  15.  
  16. const add = (a,b,c,d) => a + b + c + d;
  17.  
  18. curry(add)(1,2)(3)(4); // 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement