I do below code when I've done removed a user.
users.filter(obj => obj.id === user.id);
It's wrong because now my users object left one user object, instead I should remove the item from the list base on the id. So I wonder is there any opposite of filter function?
The opposite of filter is filter. You just need to specify what you want to keep.
For example, if you want odd numbers:
[1,2,3,4,5,6].filter(x => x%2 != 0);
if you want the opposite:
[1,2,3,4,5,6].filter(x => x%2 == 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With