Last active
March 31, 2020 11:04
-
-
Save meekg33k/bd64c0ba43d2818cca35d0d8e1779ffa to your computer and use it in GitHub Desktop.
Identity function using Generics https://medium.com/p/177b4a654ef6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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