Created
June 21, 2016 06:32
-
-
Save thakurarun/d00ce84c9f0acb556d73b5cc7290d4b6 to your computer and use it in GitHub Desktop.
find unique and duplicate values in array
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 _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