This is isn't really a question, it's a solution but I wanted to post it because I've seen it come up frequently. Feel free to suggest improvements though. I'll update my Fiddle with the results.
Using jQuery, this compares 2 arrays and outputs the differences in the two.
var array1 = [1, 2, 3, 4, 5, 6];
var array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var foo = [];
var i = 0;
jQuery.grep(array2, function(el) {
if (jQuery.inArray(el, array1) == -1) foo.push(el);
i++;
});
alert(" the difference is " + foo);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>