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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -