Function: dropWhile()
ts
function dropWhile<T>(array, predicate): T[];Drops elements from the start while the predicate returns true. 从数组头部连续丢弃满足谓词的元素。
Type Parameters
| Type Parameter | Description |
|---|---|
T | Item type / 元素类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
array | readonly T[] | Source array / 源数组 |
predicate | (item, index) => boolean | Test function / 判断函数 |
Returns
T[]
Remaining slice / 剩余元素
Example
ts
dropWhile([1, 2, 3, 4], (n) => n < 3)
// => [3, 4]Since
1.2.0