How do I find what is common between 2 lists? [duplicate]

You can try underscore.js for variety of operations in JavaScript.
_.difference : Returns the values from array that are not present in the other arrays.

_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
=> [1, 3, 4]

You can try it in python like

list(set([1, 2, 3, 4, 5]) - set([5, 2, 10]))
=> [1, 3, 4]

Leave a Comment