Skip to content

identity ​

Returns the received value without modifications.

Syntax ​

typescript
identity<T>(value: T): T

Parameters ​

NameTypeDescription
valueTThe value to be returned.

Returns ​

TypeDescription
TThe same value received as an argument.

Example ​

typescript
identity(42); // 42
identity("abc"); // "abc"

Notes ​

  • Useful as a default function or in functional pipelines.

References ​

Released under the MIT License.