last
Get the last item from a list
70 bytes
Usage
Given an array of items return the last item or a default value if no items exists.
import * as import _
_ from 'radashi'
const const fish: string[]
fish = ['marlin', 'bass', 'trout']
const const lastFish: string | undefined
lastFish = import _
_.last<string[], undefined>(array: string[], defaultValue?: undefined): string | undefinedexport last
Get the last item in an array or a default value.
last(const fish: string[]
fish) // => 'trout'const const lastItem: "bass"
lastItem = import _
_.last<readonly [], "bass">(array: readonly [], defaultValue?: "bass" | undefined): "bass"export last
Get the last item in an array or a default value.
last([], 'bass') // => 'bass'