Answers for "remove element from array in an immutable way"

0

remove element from array in an immutable way

const arr = ['a', 'b', 'c', 'd', 'e'];

const indexToRemove = 2; // the 'c'

const result = [...arr.slice(0, indexToRemove), ...arr.slice(indexToRemove + 1)];

console.log(result);
// ['a', 'b', 'd', 'e']
Posted by: Guest on February-03-2021

Code answers related to "remove element from array in an immutable way"

Code answers related to "Javascript"

Browse Popular Code Answers by Language