Generic ( <T> )
Type-independent, reusable structure.
Syntax
function name<T>(x: T): T { }Description
T is a 'type placeholder'; the actual type is determined when calling the function. It provides flexibility while maintaining type safety.
Example
Loading editor…
Expected output
10 a
When to use?
Helpers working with any type (first element, box, items).