Skip to content

dropWhile

Subhajit Sahu edited this page Jun 16, 2020 · 16 revisions

Drops values till a test passes. 🏃 📼 📦 🌔 📒

Alternatives: drop, dropWhile.
Similar: take, drop.

array.dropWhile(x, fn);
// x:  an array
// fn: test function (v, i, x)
const array = require('extra-array');

var x = [1, 2, 3, 4, 5];
array.dropWhile(x, v => v < 3);
// [ 3, 4, 5 ]

array.dropWhile(x, v => v < 4);
// [ 4, 5 ]

references

Clone this wiki locally