JSFiddle - React, Tailwind, and code Playground
by John Grivas
JavaScript
var array1 = [1,2,3,4,6,7];
var array2 = [2,5,6];
var foo = [];
var foo2 = [];
var result = [];
var i = 0;
jQuery.grep(array2, function(el) {
if (jQuery.inArray(el, array1) == -1)
{
foo.push(el);
}
else
{
foo2.push(el);
}
i++;
});
alert(foo2);alert(foo);
result = $.merge( foo2, foo)
alert(result);