Files
30-seconds-of-code/snippets/js/s/binary-function-arity.md
Angelos Chalaris 9d032ce05e Rename js snippets
2023-05-19 20:23:47 +03:00

444 B

title, type, language, tags, author, cover, dateModified
title type language tags author cover dateModified
Binary function arity snippet javascript
function
chalarangelo blue-bird 2020-10-18T23:04:45+03:00

Creates a function that accepts up to two arguments, ignoring any additional arguments.

  • Call the provided function, fn, with the first two arguments given.
const binary = fn => (a, b) => fn(a, b);
['2', '1', '0'].map(binary(Math.max)); // [2, 1, 2]