Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Identity function using Generics
const identity = <T>(arg: T): T => arg;
identity<string>('someString'); //would return 'someString'
identity<number>(12); //would return 12
identity<boolean>(false); //would return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment