1fruits = ['Banana', 'Orange', 'Apple', 'Mango'];
2
3removeFruitByIndex(index: number) {
4 this.fruits = [
5 ...this.fruits.slice(0, i),
6 ...this.fruits.slice(i + 1, this.fruits.length),
7 ];
8}
9
10
11removeFruitByValue(fruite: string) {
12 const i = this.descriptionsList.indexOf(fruite);
13 this.fruits = [
14 ...this.fruits.slice(0, i),
15 ...this.fruits.slice(i + 1, this.fruits.length),
16 ];
17}
1var fruits = ["Banana", "Orange", "Apple", "Mango", "Kiwi"];
2document.getElementById("demo").innerHTML = fruits;
3
4function myFunction() {
5 fruits.splice(2, 2);
6 document.getElementById("demo").innerHTML = fruits;
7}
1let myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon']
2let removed = myFish.splice(3, 1)
3
4// myFish is ["angel", "clown", "drum", "sturgeon"]
5// removed is ["mandarin"]