Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
What's the best way to compare two Javascript arrays and create a new array of only the matches?
var a = ["a","m"],
b = ["a","c","x","l","m"] ,
c = [], //array with matches
i = a.length,
while(i--) {
j = b.length;
while (j--) {
if (b[j] == a[i]) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment