splice element array code example
Example 1: splice from array javascript to remove
let myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon']
let removed = myFish.splice(3, 1)
Example 2: var categories_arr = this.state.categories; for (var i=0;i
javascript by Victorious Vendace
on Apr 07 2020 Donate
Comment
onDelete(category_id)
{
axios.delete('http://127.0.0.1:8000/category/delete/'+category_id)
.then(response =>{
var categories_arr = this.state.categories;
for (var i=0;i<categories_arr.length;i++)
{
if(categories_arr[i].id==category_id)
{
categories_arr.splice(i,1);
this.setState({categories:categories_arr});
}
}
});
}