Files
30-seconds-of-code/javascript/snippets/unary.md
2023-05-01 22:35:56 +03:00

407 B

title, type, tags, cover, dateModified
title type tags cover dateModified
Unary function arity snippet
function
flower-portrait-2 2020-10-22T20:24:44+03:00

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]