Skip to content

constant

constant<A>(a): () => A

Defined in: Composition/fn.ts:22

Creates a function that always returns the given value, ignoring its argument.

A

A

(): A

A

const always42 = constant(42);
always42(); // 42
[1, 2, 3].map(constant("x")); // ["x", "x", "x"]