Files
30-seconds-of-code/snippets/unary.md
Isabelle Viktoria Maciohsek 27c168ce55 Bake date into snippets
2021-06-13 13:55:00 +03:00

396 B

title, tags, firstSeen, lastUpdated
title tags firstSeen lastUpdated
unary function,beginner 2018-01-24T13:22:32+02:00 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]