Skip to content

dropRight

Subhajit Sahu edited this page Feb 3, 2021 · 12 revisions

Discard last n values only.

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


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

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

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


References

Clone this wiki locally