2020-07-29 14:04:44 +08:00
..
2020-07-28 18:09:56 +08:00
2020-07-28 18:09:56 +08:00
2020-07-29 14:04:44 +08:00
2020-07-28 18:09:56 +08:00
2020-07-28 18:09:56 +08:00

Tail of Array medium #array #4.0

by Anthony Fu @antfu

Take the Challenge

TypeScript 4.0 is recommended in this challenge

Implement a generic Tail<T> that takes an Array T and returns it's last element's type.

For example

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

type tail1 = Tail<arr1> // expected to be 'c'
type tail2 = Tail<arr2> // expected to be 1

Back Check out Solutions Share your Solutions