splice from array javascript to remove

Solutions on MaxInterview for splice from array javascript to remove by the best coders in the world

showing results for - "splice from array javascript to remove"
Fabio
29 Apr 2020
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}
Irene
01 Jun 2018
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}
Jerónimo
16 Oct 2020
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"] 
similar questions
queries leading to this page
splice from array javascript to remove