← TechnologyThe essentials of

splice(): change the array itself

Publisher: ResumeMaker • 1 source

Published: 22 Oct 2026 13:13 · Updated: 22 Oct 2026 13:13

AI source check: 21 Oct 2026 12:40. This is not editorial approval.

In a few sentences

In brief

The returned array contains the removed elements.

Useful to know

splice() removes, replaces or adds items in place. If const items = [1, 2, 3]; and execute items.splice(1, 1, 9), items becomes [1, 9, 3], and the returned value is [2]. [1]

Distinguish the changed list from the call result. It is a common mistake to save the removed items as the "new complete list". If the goal is only to read some of the data , slice is more appropriate. Before deleting by found index check also the case -1 from a failed search.

Sources

For further detail and to check the information:

  1. [1] MDN — Array.splice ↗