Guest User

Untitled

a guest
Dec 13th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. const getValue = (form, fieldName) => form[fieldName]
  2.  
  3. const form = {
  4. firstName: 'dima',
  5. lastName: 'shelomanov'
  6. }
  7.  
  8. const curry = (fn, ...args) =>
  9. (...currentArgs) => {
  10. const allArgs = [...args, ...currentArgs]
  11. return allArgs.length >= fn.length
  12. ? fn(...allArgs)
  13. : curry(fn, ...allArgs)
  14. }
  15.  
  16. const withForm = curry(getValue, form)
  17.  
  18. console.log(withForm('lastName'))
Add Comment
Please, Sign In to add comment