fruits = ['Banana', 'Orange', 'Apple', 'Mango'];
removeFruitByIndex(index: number) {
this.fruits = [
...this.fruits.slice(0, i),
...this.fruits.slice(i + 1, this.fruits.length),
];
}
removeFruitByValue(fruite: string) {
const i = this.descriptionsList.indexOf(fruite);
this.fruits = [
...this.fruits.slice(0, i),
...this.fruits.slice(i + 1, this.fruits.length),
];
}
let myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon']
let removed = myFish.splice(3, 1)
// myFish is ["angel", "clown", "drum", "sturgeon"]
// removed is ["mandarin"]
var fruits = ["Banana", "Orange", "Apple", "Mango", "Kiwi"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
fruits.splice(2, 2);
document.getElementById("demo").innerHTML = fruits;
}
let removedItem = fruits.splice(pos, 1) // this is how to remove an item
// ["Strawberry", "Mango"]