Filter Array Of Objects By Index
I want to filter array of objects by index.
- {{list.note} &l
Solution 1:
I think this will works
deleteNote(i) {
this.lists = this.lists.filter((_, index) => index !== i);
}
Solution 2:
You need to use second argument to the filter function.
let arr = this.lists.filter( (item, index) =>
item.note !== this.lists[index]
);
this.lists = arr;
Here is MDN docs for Filter
Hope this helps!
Solution 3:
By the looks of it, you want to remove an item by index?
deleteNote(i) {
this.lists.splice(i, 1);
}
The above snippet should modify the existing array and remove one element at the desired index.
Post a Comment for "Filter Array Of Objects By Index"