Created
October 6, 2013 07:01
-
-
Save mlakkadshaw/6850524 to your computer and use it in GitHub Desktop.
Exampe of _.uniq method in underscoreJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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