Returns the given constant no matter the input.

Type signature

(x: any) => any

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