justReturn
The justReturn() function builds a constant function: it ignores its argument and always returns the same value. It also exists in direct form to immediately return that value.
Interactive example
Syntax
Classic signature
typescript
function justReturn<
GenericInput extends unknown,
GenericInput extends AnyValue
>(
input: GenericInput,
input: GenericInput
): GenericInput;Curried signature
typescript
function justReturn<
GenericInput extends unknown,
GenericInput extends AnyValue
>(
input: GenericInput
): (input: GenericInput) => GenericInput;Parameters
input: The constant value to return.input(direct overload) : A value ignored, useful to stay compatible with callbacks.
Return value
- Curried overload: a function that always returns
inputregardless of the argument received. - Direct overload: the value
input.
