Skip to content

Instantly share code, notes, and snippets.

@h3h
Created October 1, 2010 00:39
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 h3h/605546 to your computer and use it in GitHub Desktop.
Save h3h/605546 to your computer and use it in GitHub Desktop.
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