Skip to content

Instantly share code, notes, and snippets.

@itrelease
Created January 24, 2010 18:21
Show Gist options
  • Save itrelease/285352 to your computer and use it in GitHub Desktop.
Save itrelease/285352 to your computer and use it in GitHub Desktop.
var Fruit = ["Apple", "Kinnow", "Mango", "Orange"];
var Citrus = ["Lemon", "Kinnow", "Orange", "Tangerine"];
function diffArrays (A, B) {
var strA = ":" + A.join("::") + ":";
var strB = ":" + B.join(":|:") + ":";
var reg = new RegExp("(" + strB + ")","gi");
var strDiff = strA.replace(reg,"").replace(/^:/,"").replace(/:$/,"");
var arrDiff = strDiff.split("::");
return arrDiff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment