🎮 TypeScript generics — 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.

any version

function firstElement(arr: any): any {
  return arr[0];
}
Pick a preset, then hit run.

<T> version

function firstElement<T>(arr: T[]): T | undefined {
  return arr[0];
}
Pick a preset, then hit run.

What just happened: pick a preset and press run to find out.