Files
30-seconds-of-code/snippets/binary.md
2020-09-15 21:52:00 +03:00

323 B

title, tags
title tags
binary 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.
const binary = fn => (a, b) => fn(a, b);
['2', '1', '0'].map(binary(Math.max)); // [2, 1, 2]