Created
March 6, 2015 15:44
-
-
Save mrroot5/220a36a4a94c496e6ca7 to your computer and use it in GitHub Desktop.
Check added and removed items from two different arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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