Files
30-seconds-of-code/snippets/over.md
Angelos Chalaris 611729214a Snippet format update
To match the starter (for the migration)
2019-08-13 10:29:12 +03:00

446 B

title, tags
title tags
over adapter,function,intermediate

Creates a function that invokes each provided function with the arguments it receives and returns the results.

Use Array.prototype.map() and Function.prototype.apply() to apply each function to the given arguments.

const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
const minMax = over(Math.min, Math.max);
minMax(1, 2, 3, 4, 5); // [1,5]