Skip to content

dropRight

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

Drops values from right. 🏃 📼 📦 🌔 📒

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

iterable.dropRight(x, [n]);
// x: an iterable
// n: number of values (1)
const iterable = require('extra-iterable');

var x = [1, 2, 3, 4, 5];
[...iterable.dropRight(x, 2)];
// [ 1, 2, 3 ]

[...iterable.dropRight(x, 3)];
// [ 1, 2 ]

references

Clone this wiki locally