Created
May 20, 2015 20:33
-
-
Save garystorey/e0d658bd64f630ecde79 to your computer and use it in GitHub Desktop.
unique.js from this discussion //http://codereview.stackexchange.com/questions/57581/how-can-i-quickly-find-unique-list-items
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
| function uniques(array) { | |
| var result = [], val, ridx; | |
| outer: | |
| for (var i = 0, length = array.length; i < length; i++) { | |
| val = array[i]; | |
| ridx = result.length; | |
| while (ridx--) { | |
| if (val === result[ridx]) continue outer; | |
| } | |
| result.push(val); | |
| } | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment