Add unary
This commit is contained in:
13
snippets/unary.md
Normal file
13
snippets/unary.md
Normal file
@ -0,0 +1,13 @@
|
||||
### unary
|
||||
|
||||
Creates a function that accepts up to one argument, ignoring any additional arguments.
|
||||
|
||||
Call the provided function, `fn`, with just the first argument given.
|
||||
|
||||
```js
|
||||
const unary = fn => val => fn(val);
|
||||
```
|
||||
|
||||
```js
|
||||
['6', '8', '10'].map(unary(parseInt)); // [6, 8, 10]
|
||||
```
|
||||
Reference in New Issue
Block a user