Files
30-seconds-of-code/snippets/unary.md
Angelos Chalaris 6f3bc03872 Update unary.md
2020-01-13 10:07:34 +02:00

315 B

title, tags
title tags
unary function,beginner

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

Call the provided function, fn, with just the first argument given.

const unary = fn => val => fn(val);
['6', '8', '10'].map(unary(parseInt)); // [6, 8, 10]