Deviopath › TypeScript

Generic First Item

Easy · Generics

Write a generic function first<T>(items: T[]): T | undefined that returns the first item of the array, or undefined if it is empty.

Next: Last Item or Fallback