Files
30-seconds-of-code/snippets/over.md
Isabelle Viktoria Maciohsek 8bf67754ce Make expertise a field
2022-03-01 20:21:45 +02:00

554 B

title, tags, expertise, firstSeen, lastUpdated
title tags expertise firstSeen lastUpdated
Invoke functions on arguments function intermediate 2018-01-23T21:02:17+02:00 2020-10-21T21:54:53+03:00

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]