Skip to content

Instantly share code, notes, and snippets.

@BlackPrincess
Created May 7, 2013 08:38
Show Gist options
  • Select an option

  • Save BlackPrincess/5531149 to your computer and use it in GitHub Desktop.

Select an option

Save BlackPrincess/5531149 to your computer and use it in GitHub Desktop.
jquery distinct(仮)
$.extend({
distinct: function (array) {
var u = {}, a = [];
for(var i = 0, l = array.length; i < l; ++i){
if(u.hasOwnProperty(array[i])) {
continue;
}
a.push(array[i]);
u[array[i]] = 1;
}
return a;
}
});
$.fn.extend({
distinct : function() {
return this.pushStack( $.distinct(this));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment