WPM bersih0
WPM0
Ketepatan100%
Lupa Lenyap0s
Waktu—
Aksara mata rantai0
koreksi0
Ralat0
Kemajuan Internet0%
Nama Caps Lock On

Panduan petunjuk kode baca code code code code lema

Bahasa Pemrograman Bahasa
TypeScript
Kesulitan Liar
SederhanaCity in Argentina

Return the first element while preserving its type.

function firstItem<T>(items: T[]): T | undefined {
  return items[0];
}

const firstNumber = firstItem([4, 8, 15]);
const firstName = firstItem(["Ada", "Lin"]);