Last active
August 29, 2015 14:19
-
-
Save abrahamfast/66d3adcef53c2a227227 to your computer and use it in GitHub Desktop.
function unique 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 a=[1,5,1,6,4,5,2,5,4,3,1,2,6,6,3,3,2,4]; | |
function unique(list) { | |
var result = []; | |
$.each(list, function(i, e) { | |
if ($.inArray(e, result) == -1) result.push(e); | |
}); | |
return result; | |
} | |
var unique = a.filter(function(itm,i,a){ | |
return i == a.indexOf(itm); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Work Easy 😃