Files
30-seconds-of-code/snippets/unary.md
Angelos Chalaris 7f2297496a Add unary
2018-01-24 13:22:32 +02:00

14 lines
280 B
Markdown

### 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]
```