Say I have two sets (arrays):
a = [1,2,3];
b = [2,3,5];
and I want 1,2,3,5 out only.
What is the most terse way to do this? Or, failing that, what is a way to do this?
Say I have two sets (arrays):
a = [1,2,3];
b = [2,3,5];
and I want 1,2,3,5 out only.
What is the most terse way to do this? Or, failing that, what is a way to do this?
The following post should help...about half way down is a union with a library reference.
How to merge two arrays in Javascript and de-duplicate items
var a = [1,2,3];
var b = [2,3,5];
//Concat both arrays [1,2,3,2,3,5]
var result = a.concat(b).filter(function(value, index, self) { //array unique
return self.indexOf(value) === index;
});
console.log(result); //[1, 2, 3, 5];