jQuery Simple Example
HTML
<script src="//www.addressfinder.co.nz/assets/v2/widget.js"></script>
CSS
body {
padding: 5px;
}
label {
font-weight: bold;
}
input[type=text] {
width: 20em
}
p {
margin: 1em 0 0;
}
JavaScript
var list1 = [6, 7, 3, 4, 1, 2];
var list2 = [2, 4, 6, 5, 1, 9, 8, 7, 8];
var newArray = [];
$.each(list1, function(i, value) {
console.log($.inArray(value, list2));
if ($.inArray(value, list2) == -1) {
newArray.push(value);
}
});
$.each(list2, function(i, value) {
if ($.inArray(value, list1) == -1) {
newArray.push(value);
}
});
console.log(newArray);