any vs <T>
Pick a dataset, then click "Call .toUpperCase() on the first item."
Both cards run the same operation on the same data — one typed
any, one typed generically. Watch what each one catches, and when.
function firstElement(arr: any): any {
return arr[0];
}
function firstElement<T>(arr: T[]): T | undefined {
return arr[0];
}
What just happened: pick a preset and press run to find out.