Skip to content

Instantly share code, notes, and snippets.

@Magellol
Created March 27, 2017 16:56
Show Gist options
  • Save Magellol/7262cf9b45f62eda28cf1c7e647bc6ab to your computer and use it in GitHub Desktop.
Save Magellol/7262cf9b45f62eda28cf1c7e647bc6ab to your computer and use it in GitHub Desktop.
Removing an index from an array.
/**
* Remove an index from an array.
* This creates a new array without the index we're removing.
* Because of that, indexes are re-created so there isn't any empty spot.
*
*/
export function removeIndexFrom(array, indexToRemove) {
return [
...array.slice(0, indexToRemove),
...array.slice(indexToRemove + 1),
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment