阅读提示:
每个方法都有相应的描述、语法、参数、返回值、注意项(可选)、例子(可选)。
语法中的[]
里面中的内容表示参数为可选参数。
Array.from()
描述:从一个类似数组或可迭代对象中创建一个新的数组实例。
语法:
new_array = Array.from(arrayLike[, callback(element[, index[, array]])[, thisArg]]);
阅读提示:
每个方法都有相应的描述、语法、参数、返回值、注意项(可选)、例子(可选)。
语法中的[]
里面中的内容表示参数为可选参数。
Array.from()
描述:从一个类似数组或可迭代对象中创建一个新的数组实例。
语法:
new_array = Array.from(arrayLike[, callback(element[, index[, array]])[, thisArg]]);
by jiangshan (@jiangshanmeta) #中等 #union
Given an array of unique elements, return all possible subsequences.
A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements.
by Hong (@RThong) #中等 #union #string
判断一个string类型中是否有相同的字符
type CheckRepeatedChars<'abc'> // false
type CheckRepeatedChars<'aba'> // true
by jiangshan (@jiangshanmeta) #中等 #string
Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. (Inspired by leetcode 387)
by Pineapple (@Pineapple0919) #中等 #array
Implement the type version of Array.indexOf
, indexOf<T, U>
takes an Array T
, any U
and returns the index of the first U
in Array T
.
by Pineapple (@Pineapple0919) #中等 #array
Implement the type version of Array.join
, Join<T, U>
takes an Array T
, string or number U
and returns the Array T
with U
stitching up.
by Krzysztof "Wokay" Łokaj (@wokayme) #中等 #map #object #utils
Implement MapTypes<T, R>
which will transform types in object T to different types defined by type R which has the following structure
type StringToNumber = {
mapFrom: string; // value of key which value is string
mapTo: number; // will be transformed for number
}
by Lo (@LoTwT) #中等 #tuple
构造一个给定长度的元组。
例如
type result = ConstructTuple<2> // 期望得到 [unknown, unkonwn]
by AaronGuo (@HongxuanG) #中等
Sometimes we want to limit the range of numbers...
For examples.
type result = NumberRange<2 , 9> // | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
by Homyee King (@HomyeeKing) #中等 #array #application #string
Given an array of strings, do Permutation & Combination.
It's also useful for the prop types like video controlsList