Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Created January 11, 2022 05:29
Show Gist options
  • Save ancyrweb/f4bde1b253e7708a24f7ac48c93d42d8 to your computer and use it in GitHub Desktop.
Save ancyrweb/f4bde1b253e7708a24f7ac48c93d42d8 to your computer and use it in GitHub Desktop.
const elements = [1, 2, 3, 4, 5];
const indexToRemove = 2; // starts from 0, so it targets the third element
const nextElements = [
...elements.slice(0, indexToRemove),
...elements.slice(indexToRemove + 1)
]; // [1, 2, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment