Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

出堆 中等 #array

by Anthony Fu @antfu

接受挑战    English 日本語 한국어

在此挑战中建议使用TypeScript 4.0

实现一个通用Pop<T>,它接受一个数组T,并返回一个由数组T的前length-1项以相同的顺序组成的数组。

例如

type arr1 = ['a', 'b', 'c', 'd']
type arr2 = [3, 2, 1]

type re1 = Pop<arr1> // expected to be ['a', 'b', 'c']
type re2 = Pop<arr2> // expected to be [3, 2]

额外:同样,您也可以实现ShiftPushUnshift吗?


返回首页 分享你的解答 查看解答

相关挑战

14・第一个元素 15・最后一个元素