Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

std/collections/mod.ts>dropWhile

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function dropWhile
import { dropWhile } from "https://deno.land/std@0.139.0/collections/mod.ts";

Returns a new array that drops all elements in the given collection until the first element that does not match the given predicate

Example:

import { dropWhile } from "https://deno.land/std@0.139.0/collections/mod.ts";
import { assertEquals } from "https://deno.land/std@0.139.0/testing/asserts.ts";

const numbers = [ 3, 2, 5, 2, 5 ]
const dropWhileNumbers = dropWhile(numbers, i => i !== 2)

assertEquals(dropWhileNumbers, [2, 5, 2, 5 ])

Parameters

array: readonly T[]
predicate: (el: T) => boolean