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

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -