Add binary

This commit is contained in:
Angelos Chalaris
2020-05-13 13:36:36 +03:00
parent f6ba4862ea
commit ae3d577f6f

16
snippets/binary.md Normal file
View File

@ -0,0 +1,16 @@
---
title: binary
tags: function,beginner
---
Creates a function that accepts up to two arguments, ignoring any additional arguments.
Call the provided function, `fn`, with the first two arguments given.
```js
const binary = fn => (a, b) => fn(a, b);
```
```js
['2', '1', '0'].map(binary(Math.max)); // [2, 1, 2]
```