Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getValue = (form, fieldName) => form[fieldName]
- const form = {
- firstName: 'dima',
- lastName: 'shelomanov'
- }
- const curry = (fn, ...args) =>
- (...currentArgs) => {
- const allArgs = [...args, ...currentArgs]
- return allArgs.length >= fn.length
- ? fn(...allArgs)
- : curry(fn, ...allArgs)
- }
- const withForm = curry(getValue, form)
- console.log(withForm('lastName'))
Add Comment
Please, Sign In to add comment