Merging two collections using Underscore.JS

The following will:

  • create a new array that contains all the elements of c1 and c2. See union.
  • from that mix, create a new array that contains only the unique elements. See uniq.

Note that this would work only if all your objects have the property a.

_.uniq(_.union(c1, c2), false, function(item, key, a){ return item.a; });

You can find other options in this question.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)