1let originalArray = [
2 {name: 'John', age: 23, color: 'red'},
3 {name: 'Ann', age: 21, color: 'blue'},
4 {name: 'Mike', age: 13, color: 'green'}
5];
6
7let filteredArray = originalArray.filter(value => value.age > 18);
1var colors = ["red","blue","car","green"];
2var carIndex = colors.indexOf("car");//get "car" index
3//remove car from the colors array
4colors.splice(carIndex, 1); // colors = ["red","blue","green"]
1const array = [2, 5, 9];
2
3//Get index of the number 5
4const index = array.indexOf(5);
5//Only splice if the index exists
6if (index > -1) {
7 //Splice the array
8 array.splice(index, 1);
9}
10
11//array = [2, 9]
12console.log(array);