Created
October 1, 2010 00:39
-
-
Save h3h/605546 to your computer and use it in GitHub Desktop.
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
if (!Array.prototype.uniq) | |
{ | |
Array.prototype.uniq = function(fun) | |
{ | |
var seen = {}; | |
return this.filter(function (el) { | |
var key = typeof (fun) == "function" ? fun(el) : el; | |
var r = !seen[key]; | |
seen[key] = true; | |
return r; | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment