# .drop()

> The `.drop()` JS method of the `Iterator` object returns a new iterator that skips a given number of values.

## How do I skip the first values of an iterator in JavaScript?

The method that returns a new iterator which skips the given number of values from the beginning of the original iterator and then yields the rest.

- Topic: Iterator
- Type: method
- Browser support: Chrome 122+, Chrome Android 122+, Edge 122+, Firefox 131+, Firefox Android 131+, Safari 18.4+, Safari iOS 18.4+

## Example

Wrong:

```js
const all = Array.from(rows.values());
const page = all.slice(20, 30);
```

Right:

```js
const page = rows.values()
  .drop(20)
  .take(10)
  .toArray();
```

`drop()` and `take()` skip and limit lazily, so only the needed rows are read instead of copying all of them first.

## Common mistakes

- Expecting `drop()` to run right away, while it is lazy until the iterator is consumed.

## Key points

- The count is a non-negative number, otherwise `drop()` throws a `RangeError`.
- `drop()` is chained with `take()` for paging instead of converting to an array first.

## Interview questions

### What is the iterator version of `slice()`?

Chain `drop(start)` and `take(count)`. For example, `it.drop(5).take(5)` yields the sixth to tenth values.

### Does `drop()` throw if the count is larger than the iterator?

No. It skips everything, and the resulting iterator finishes with no values.

## Related cards

- [.take()](https://wonderium.dev/js/iterator-take.md)
- [Iterator](https://wonderium.dev/js/iterator.md)
- [Array.slice()](https://wonderium.dev/js/array-slice.md)
- [Generator](https://wonderium.dev/js/generator.md)

---

- Level: [JavaScript](https://wonderium.dev/js.md)
- HTML version: https://wonderium.dev/js/iterator-drop
- Last updated: 2026-11-25
