Skip to content

Instantly share code, notes, and snippets.

@meekg33k
Last active March 31, 2020 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meekg33k/bd64c0ba43d2818cca35d0d8e1779ffa to your computer and use it in GitHub Desktop.
Save meekg33k/bd64c0ba43d2818cca35d0d8e1779ffa to your computer and use it in GitHub Desktop.
Identity function using Generics https://medium.com/p/177b4a654ef6
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