Skip to content

Instantly share code, notes, and snippets.

@mlakkadshaw
Created October 6, 2013 07:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mlakkadshaw/6850524 to your computer and use it in GitHub Desktop.
Exampe of _.uniq method in underscoreJS
var data = ['a','b','c','a','s','b']; //This array contains duplicates
_.uniq(data);
//Ouput
['a','b','c','s','b'] //duplicates removed
//Also works on array of objects
var objs = [{name:"Samsung"}, {name: "LG"}, {name:"Sony"}, {name:"Samsung"}]; //contains duplicate objects
_.uniq(objs);
//output
[{name:"Samsung"}, {name: "LG"}, {name:"Sony"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment