I want to remove common elements of two arrays in jquery. I have two arrays:
A = [0,1,2,3]
B = [2,3]
and result should be [0, 1]
.
Please help
You can filter array A by checking its elements position in array B:
C = A.filter(function(val) {
return B.indexOf(val) == -1;
});
Demo
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