last

Variable

取数组的最后一个元素,数组为空时返回默认值(默认为 `undefined`)

Signature

const last: <T>(array: readonly T[], defaultValue?: T | null | undefined) => T | null | undefined

Examples

last([1, 2, 3]) // 3
last([], 'empty') // 'empty'

Source

node_modules/.pnpm/radash@12.1.1/node_modules/radash/dist/index.d.ts:47