function first
first(value: string): string | undefined

Returns the first thing in a list. If the value is a string, then it will return the first character.

Examples

Example 1

first("hello"); // "h"
first([1, 2, 3]); // 1
first([]); // undefined

Parameters

value: string

Return Type

string | undefined
first<T>(list: T[]): T | undefined

Type Parameters

Parameters

list: T[]

Return Type

T | undefined