es-toolkit/docs/reference/function/identity.md
2024-10-24 18:10:25 +09:00

356 B

identity

Returns the input value unchanged.

Signature

function identity<T>(x: T);

Parameters

  • x (T): The value to be returned.

Returns

(T): The input value.

Examples

// Returns 5
identity(5);

// Returns 'hello'
identity('hello');

// Returns { key: 'value' }
identity({ key: 'value' });