Skip to content

Instantly share code, notes, and snippets.

@thakurarun
Created June 21, 2016 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thakurarun/d00ce84c9f0acb556d73b5cc7290d4b6 to your computer and use it in GitHub Desktop.
Save thakurarun/d00ce84c9f0acb556d73b5cc7290d4b6 to your computer and use it in GitHub Desktop.
find unique and duplicate values in array
var _unique = function (arr) {
var h = [], t = [];
arr.forEach(function (n) {
if (h.indexOf(n) == -1)
h.push(n);
else t.push(n);
});
return [h, t];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment