How to get the union of two sets in javascript -


this question has answer here:

say have 2 sets (arrays):

a = [1,2,3]; b = [2,3,5]; 

and want 1,2,3,5 out only.

what terse way this? or, failing that, way this?

var = [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]; 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -