1//you can use two functions depending of what you want to do:
2
3let animals1 = ["dog", "cat", "mouse"]
4delete animals1[1]
5/*this deletes all the information inside "cat" but the element still exists
6so now you'll have this:*/
7console.log(animals1)//animals1 = ["dog", undefined, "mouse"]
8
9//if you want to delete it completely, you have to use array.splice:
10
11let animals2 = ["dog", "cat", "mouse"]
12animals2.splice(1, 1)
13/*the first number means the position from which you want to start to delete
14and the second is how much elements will be deleted*/
15console.log(animals2)//animals2 = ["dog", "mouse"]
16/*Now you don't have undefined
17If you did this:*/
18let animals3 = ["dog", "cat", "mouse"]
19animals3.splice(0, 2)//you'll have this:
20console.log(animals3)//animals 3 = "mouse"
21/*This happens because I put a 2 in the second parameter so it deleted
22two elements from position 0
23Try copying this code in your console and whatch*/
1var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
2var filtered = array.filter(function(value, index, arr){
3 return value > 5;
4});
5//array => [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
6//filtered => [6, 7, 8, 9]