Exampe of _.uniq method in underscoreJS
This file contains 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