Always return the given value.

Type signature

(x: any) => any

Examples

identity(5);
// ⇒ 5
Try in REPL
identity("test");
// ⇒ "test"
Try in REPL

Questions

  • How to use the identity function?
  • Where and why is identity function useful?

TypeScript sourceJavaScript source