Skip to content

Instantly share code, notes, and snippets.

@mrroot5
Created March 6, 2015 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrroot5/220a36a4a94c496e6ca7 to your computer and use it in GitHub Desktop.
Save mrroot5/220a36a4a94c496e6ca7 to your computer and use it in GitHub Desktop.
Check added and removed items from two different arrays
function checkArrayDifferences (array1, array2) {
"use strict";
var removed = $(array1).not(array2).get(),
added = $(array2).not(array1).get();
return {'removed': removed, 'added': added};
}
var array1 = [1,2,3,4],
array2 = [2,3,6],
differences;
differences = checkArrayDifferences(array1, array2);
window.console.log(differences);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment