How do js remove duplicate values from two arrays?

How do js remove duplicate values from two arrays?

As shown below:

a = [1,2,3,4,5]
b = [3,4,5]

a Only [1,2]

Answer:

a = [1, 2, 3, 4, 5];
b = [3, 4, 5];
a = a.filter(item => b.indexOf(item) == -1);
console.log(a); // [1, 2]

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *