[Home] > Snippets  > Languages  > JavaScript  > Fn  >  Create a function that accepts a single argument

Create a function that accepts a single argument

JavaScript

const unary = (fn) => (arg) => fn(arg)

Examples

['1', '2', '3', '4', '5'].map(unary(parseInt)) // [1, 2, 3, 4, 5]