Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update currying.md
  • Loading branch information
Swap76 authored Oct 17, 2019
commit cdb577b12fb6014c98f5db7832b1124da610a31a
14 changes: 9 additions & 5 deletions docs/JavaScript_Advance/currying.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
Currying is a technique of evaluating function with multiple arguments, into sequence of function with single argument.

## Where we use Currying?
> When we want a function, instead of taking all arguments at one time, takes the first one and return a new function that takes the second one and returns a new function which takes the third one, and so forth, until all arguments have been fulfilled.
When we want a function, instead of taking all arguments at one time, takes the first one and return a new function that takes the second one and returns a new function which takes the third one, and so forth, until all arguments have been fulfilled.

> When we want to avoid passing the same variable again and again.
When we want to avoid passing the same variable again and again.

> When we want the little pieces to be configured and reused with ease.
When we want the little pieces to be configured and reused with ease.

## How we make Currying?
We know that currying is the process of taking a function with multiple arguments and turning it into a sequence of functions each with only a single argument.

For example:
`const notCurry = (x, y, z) => x + y + z; // a regular function`
```js
const notCurry = (x, y, z) => x + y + z; // a regular function
```
Which will be turned into :
`const curry = x => y => z => x + y + z; // a curry function`
```js
const curry = x => y => z => x + y + z; // a curry function
```