last (函数式编程)
创建一个返回数组最后一个值的函数。与函数式编程的 pipe 一起使用。
typescript
const result = pipe(array, last());用法
last 返回管道中数组的最后一个值。如果数组为空,则返回 undefined。
typescript
import { last, pipe } from 'es-toolkit/fp';
pipe([1, 2, 3], last()); // => 3
pipe([], last()); // => undefined参数
此函数不接收参数;请以 last() 的形式调用。
返回值
((array: readonly T[]) => T | undefined): 一个将 readonly T[] 映射为其最后一个值的函数。

