SnipZard
Search snippets
Home
Portfolio
Contact
Generics
Generics allow the creation of reusable components that work with different types.
Snippet:
function
identity
<
T
>
(arg: T): T
{
return
arg
;
}
Copy Code
Example:
const
numberIdentity
=
identity
<
number
>
(42);
Copy Code