combining performing _.uniq with _.isEqual in lodash -
lodash provides method _.uniq()
find unique elements array, comparison function used strict equality ===
, while want use _.isequal()
, satisfies:
_.isequal([1, 2], [1, 2]) // true
is there way perform _.uniq()
_.isequal()
, without writing own method?
as of lodash v4 there's _.uniqwith(array, _.isequal)
. docs:
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; _.uniqwith(objects, _.isequal); // → [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
more info: https://lodash.com/docs#uniqwith
Comments
Post a Comment