Revision: 70332
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 16, 2016 06:45 by rain15
Initial Code
function diff(arr1, arr2) { var newArr = []; newArr = arr1.diff(arr2).concat(arr2.diff(arr1)); return newArr; } Array.prototype.diff = function(a) { return this.filter(function(i) {return a.indexOf(i) < 0;}); }; function isSame(val1, val2) { return val1 === val2; } diff([1, "calf", 3, "piglet"], [1, "calf", 3, 4] );
Initial URL
Initial Description
Compare two arrays and return a new array with any items only found in one of the original arrays. ex., [1, "calf", 3, "piglet"], [1, "calf", 3, 4] should return ["piglet", 4].
Initial Title
Compare two arrays and return a new array with any items only found in one of the original arrays.
Initial Tags
Initial Language
JavaScript