Unary function arity

JavaScript, Function · Oct 22, 2020

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

  • Call the provided function, fn, with just the first argument supplied.
const unary = fn => val => fn(val);
['6', '8', '10'].map(unary(parseInt)); // [6, 8, 10]

More like this

  • Function arity

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

    JavaScript, Function · Oct 18, 2020

  • Binary function arity

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

    JavaScript, Function · Oct 18, 2020

  • Invoke functions on arguments

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

    JavaScript, Function · Oct 21, 2020