Files
30-seconds-of-code/snippets/unary.md
Isabelle Viktoria Maciohsek aa425812b4 Update snippet descriptions
2020-10-22 20:24:44 +03:00

17 lines
320 B
Markdown

---
title: unary
tags: function,beginner
---
Creates a function that accepts up to one argument, ignoring any additional arguments.
- Call the provided function, `fn`, with just the first argument supplied.
```js
const unary = fn => val => fn(val);
```
```js
['6', '8', '10'].map(unary(parseInt)); // [6, 8, 10]
```