Question: how to find difference between 2 arrays in javascript?
Answer: indexOf() method. var first = [ 1, 2, 3, 4, 5 ]; var second = [ 4, 5, 6 ]; var difference = first.filter(x => second.indexOf(x) === -1); console.log(difference); /* Output: [ 1, 2, 3] */ ... 
ES7 includes() method. var first = [ 1, 2, 3, 4, 5 ]; var second = [ 4, 5, 6 ]; var difference = first.filter(x => ! ... 
ES6 Set Object.