Skip to content

Instantly share code, notes, and snippets.

@piyonishi
Created July 8, 2013 05:57
Show Gist options
  • Save piyonishi/5946499 to your computer and use it in GitHub Desktop.
Save piyonishi/5946499 to your computer and use it in GitHub Desktop.
Array.prototype.distinct = function() {
var u = {}, a = [];
for(var i = 0, l = this.length; i < l; ++i){
if(u.hasOwnProperty(this[i])) {
continue;
}
a.push(this[i]);
u[this[i]] = 1;
}
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment