1const index = array.indexOf(item);
2if (index > -1) {
3 array.splice(index, 1);
4}
1
2
3 var arr = [1, 2, 3, 4, 5, 5, 6, 7, 8, 5, 9, 0];
4
5 for( var i = 0; i < arr.length; i++){
6
7 if ( arr[i] === 5) {
8 arr.splice(i, 1);
9 i--;
10 }
11 }
12
13 //=> [1, 2, 3, 4, 6, 7, 8, 9, 0]
14
15
1const items = ['a', 'b', 'c', 'd', 'e', 'f']
2const i = 2
3const filteredItems = items.slice(0, i).concat(items.slice(i + 1, items.length))
4// ["a", "b", "d", "e", "f"]
5