Skip to content

Function: dropWhile()

ts
function dropWhile<T>(array, predicate): T[];

Drops elements from the start while the predicate returns true. 从数组头部连续丢弃满足谓词的元素。

Type Parameters

Type ParameterDescription
TItem type / 元素类型

Parameters

ParameterTypeDescription
arrayreadonly T[]Source array / 源数组
predicate(item, index) => booleanTest function / 判断函数

Returns

T[]

Remaining slice / 剩余元素

Example

ts
dropWhile([1, 2, 3, 4], (n) => n < 3)
// => [3, 4]

Since

1.2.0

Released under the MIT License.