Returns the given constant no matter the input.

Type signature

<T>(x: T) => () => T

Examples

constant(3)("anything");
// ⇒ 3
Try in REPL

Questions

  • How to create a function that always returns the same value despite given arguments?

TypeScript sourceJavaScript source