Skip to content

Unshift

题目

实现类型版本的 Array.unshift

例如:

typescript
type Result = Unshift<[1, 2], 0>; // [0, 1, 2,]

解答

ts
type Unshift<T extends unknown[], U> = [...[U], ...T]

Released under the MIT License.